gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py
branchtrunk
changeset 800 2b1824e138b1
parent 794 02ba1859ddc0
child 803 b1d0964060b3
     1.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Fri Aug 03 21:42:55 2007 +0100
     1.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Mon Aug 13 22:29:00 2007 +0100
     1.3 @@ -27,8 +27,24 @@
     1.4      proc = None
     1.5  
     1.6      def __init__(self, params):
     1.7 +        self.status = 0
     1.8          transcoder.Transcoder.__init__(self, params)
     1.9          self.opts = []
    1.10 +        self.opts.append (self.gmencoder_path)
    1.11 +        self.opts.append ("-d")
    1.12 +        self._parser_params ()
    1.13 +
    1.14 +        outfile = self.params_first("outfile", "")
    1.15 +
    1.16 +        if outfile != "":
    1.17 +            path = os.path.join(sys.path[0], ".transcoded", outfile)
    1.18 +            self._insert_param("-o", "file://%s" % path)
    1.19 +        else:
    1.20 +            self._insert_param ("-o", "fd://%d" % outfd.fileno())
    1.21 +            self.opts.append ("-c")
    1.22 +
    1.23 +        cmd = " ".join(self.opts)
    1.24 +
    1.25      # __init__()
    1.26  
    1.27      def _insert_param (self, name, value):
    1.28 @@ -50,21 +66,6 @@
    1.29      # _parse_params
    1.30  
    1.31      def start(self, outfd):
    1.32 -        self.status = 0
    1.33 -        self.opts.append (self.gmencoder_path)
    1.34 -        self.opts.append ("-d") 
    1.35 -        self._parser_params ()
    1.36 -
    1.37 -        outfile = self.params_first("outfile", "")
    1.38 -
    1.39 -        if outfile != "":
    1.40 -            path = os.path.join(sys.path[0], ".transcoded", outfile)
    1.41 -            self._insert_param("-o", "file://%s" % path)
    1.42 -        else:
    1.43 -            self._insert_param ("-o", "fd://%d" % outfd.fileno())
    1.44 -            self.opts.append ("-c")
    1.45 -
    1.46 -        cmd = " ".join(self.opts)
    1.47          self.log.info(self.tid, "GMencoder: %s" % cmd)
    1.48  
    1.49          try:
    1.50 @@ -75,23 +76,18 @@
    1.51              outfd.write("Error: GMencoder: %s" % e)
    1.52              return False
    1.53  
    1.54 -        if outfile:
    1.55 -            outfd.write("OK   ")
    1.56 -
    1.57          try:
    1.58              while (self.proc and self.proc.poll() == None):
    1.59                  r, w, x = select.select([self.proc.stdout], [], [], 0)
    1.60                  if self.proc.stdout in r:
    1.61                      progress = self.proc.stdout.readline()
    1.62                      if (progress.find ("PROGRESS") >= 0):
    1.63 -                        self.log.info (self.tid, "%s" % progress)
    1.64                          self.status = progress.split (":")[1]
    1.65          except Exception, e:
    1.66              self.log.error(self.tid, "Problems handling data: %s" % e)
    1.67              return False
    1.68  
    1.69          self.status = 100;
    1.70 -        self.log.info(self.tid, "OK: Done")
    1.71          return True
    1.72      # start()
    1.73  
    1.74 @@ -100,7 +96,6 @@
    1.75          if self.proc:
    1.76              self.log.info(self.tid, "Stopped GMencoder plugin")
    1.77              try:
    1.78 -                self.proc.stdin.write("QUIT\n")
    1.79                  os.kill(self.proc.pid, signal.SIGKILL)
    1.80                  self.proc.wait()
    1.81              except Exception, e:
    1.82 @@ -109,4 +104,10 @@
    1.83              self.proc = None
    1.84      # stop()
    1.85  
    1.86 +    def get_progress(self):
    1.87 +        return self.status
    1.88 +
    1.89 +    def get_lenght(self):
    1.90 +        return -1
    1.91 +
    1.92  # TranscoderGMencoder