gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py
branchtrunk
changeset 719 668ecfca1789
parent 718 3fbcd3d9b2d1
child 723 f5f7abc760aa
     1.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Tue May 29 21:24:48 2007 +0100
     1.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Wed May 30 14:43:43 2007 +0100
     1.3 @@ -37,12 +37,13 @@
     1.4  
     1.5      def _parser_params (self):
     1.6          self._insert_param("-i", \
     1.7 -            "%s://%s" % (self.params_first("type", "file"), self.params_first("uri", "")))
     1.8 +            "%s://%s" % (self.params_first("type", "file"),
     1.9 +                         self.params_first("uri", "")))
    1.10          self._insert_param("--video-encode", self.params_first("ve", ""))
    1.11          self._insert_param("--video-opts", "bitrate=200,pass=2,quantizer=5")
    1.12          self._insert_param("--video-fps", self.params_first("fps", ""))
    1.13 -        self._insert_param("--video-width", self.params_first("width", ""))
    1.14 -        self._insert_param("--video-height", self.params_first("height", ""))
    1.15 +        self._insert_param("--video-width", self.params_first("width", "320"))
    1.16 +        self._insert_param("--video-height", self.params_first("height", "240"))
    1.17          self._insert_param("--audio-rate", "32000")
    1.18          self._insert_param("--audio-encode", self.params_first("ae", ""))
    1.19      # _parse_params
    1.20 @@ -53,10 +54,11 @@
    1.21          self._insert_param ("-o", "fd://%d" % outfd.fileno())
    1.22  
    1.23          cmd = " ".join(self.opts)
    1.24 -        self.log.info ("GMencoder: %s", cmd)
    1.25 +        self.log.info(self.tid, "GMencoder: %s" % cmd)
    1.26  
    1.27          try:
    1.28 -            self.proc = subprocess.Popen(self.opts, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    1.29 +            self.proc = subprocess.Popen(self.opts, stdin=subprocess.PIPE,
    1.30 +                                         stdout=subprocess.PIPE)
    1.31          except Exception, e:
    1.32              self.log.error(self.tid, "Error executing GMencoder: %s" % e)
    1.33              return False
    1.34 @@ -66,12 +68,11 @@
    1.35                  r, w, x = select.select([self.proc.stdout], [], [], 0)
    1.36                  if self.proc.stdout in r:
    1.37                      progress = self.proc.stdout.readline()
    1.38 -                    self.log.info ("stdout %s" % progress)
    1.39 +                    self.log.debug(self.tid, "stdout %s" % progress)
    1.40                      if (progress.find ("PROGRESS") >= 0):
    1.41                          self.status = progress.split (":")[1]
    1.42 -                        #if (progress.find ("DONE") >= 0):
    1.43 -                        #	break
    1.44 -			self.log.info ("Process exit")
    1.45 +                    else:
    1.46 +			self.log.info(self.tid, "Process exit")
    1.47          except Exception, e:
    1.48              self.log.error(self.tid, "Problems handling data: %s" % e)
    1.49              return False
    1.50 @@ -82,13 +83,10 @@
    1.51  
    1.52      def stop(self):
    1.53          if self.proc:
    1.54 -            self.log.info ("STOPED GMencoder plugin")
    1.55 +            self.log.info(self.tid, "Stopped GMencoder plugin")
    1.56              try:
    1.57 -                self.proc.stdin.write ("QUIT\n")
    1.58 -            except Exception, e:
    1.59 -                pass
    1.60 -
    1.61 -            try:
    1.62 +                self.proc.stdin.write("QUIT\n")
    1.63 +                os.kill(self.proc.pid, signal.SIGKILL)
    1.64                  self.proc.wait()
    1.65              except Exception, e:
    1.66                  pass