gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py
branchtrunk
changeset 738 293e6c9546e5
parent 723 f5f7abc760aa
child 748 bf9dac4bdc5d
     1.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Wed May 30 23:14:38 2007 +0100
     1.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Fri Jun 01 15:24:34 2007 +0100
     1.3 @@ -3,9 +3,10 @@
     1.4  __author__ = "Renato Filho"
     1.5  __author_email__ = "renato.filho@indt.org.br"
     1.6  __license__ = "GPL"
     1.7 -__version__ = "0.1"
     1.8 +__version__ = "0.2"
     1.9  
    1.10  import os
    1.11 +import sys
    1.12  import shlex
    1.13  import signal
    1.14  import subprocess
    1.15 @@ -51,7 +52,14 @@
    1.16      def start(self, outfd):
    1.17          self.opts.append (self.gmencoder_path)
    1.18          self._parser_params ()
    1.19 -        self._insert_param ("-o", "fd://%d" % outfd.fileno())
    1.20 +
    1.21 +        outfile = self.params_first("outfile", None)
    1.22 +
    1.23 +        if outfile:
    1.24 +            path = os.path.join(sys.path[0], ".transcoded", outfile)
    1.25 +            self._insert_param("-o", "file://%s" % path)
    1.26 +        else:
    1.27 +            self._insert_param ("-o", "fd://%d" % outfd.fileno())
    1.28  
    1.29          cmd = " ".join(self.opts)
    1.30          self.log.info(self.tid, "GMencoder: %s" % cmd)
    1.31 @@ -60,9 +68,13 @@
    1.32              self.proc = subprocess.Popen(self.opts, stdin=subprocess.PIPE,
    1.33                                           stdout=subprocess.PIPE)
    1.34          except Exception, e:
    1.35 -            self.log.error(self.tid, "Error executing GMencoder: %s" % e)
    1.36 +            self.log.error(self.tid, "Error: executing GMencoder: %s" % e)
    1.37 +            outfd.write("Error: GMencoder: %s" % e)
    1.38              return False
    1.39  
    1.40 +        if outfile:
    1.41 +            outfd.write("OK   ")
    1.42 +
    1.43          try:
    1.44              while (self.proc and self.proc.poll() == None):
    1.45                  r, w, x = select.select([self.proc.stdout], [], [], 0)
    1.46 @@ -75,6 +87,7 @@
    1.47              self.log.error(self.tid, "Problems handling data: %s" % e)
    1.48              return False
    1.49  
    1.50 +        self.log.info(self.tid, "OK: Done")
    1.51          return True
    1.52      # start()
    1.53