diff -r 02ba1859ddc0 -r e51af4d0caf5 gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Fri Aug 03 21:42:55 2007 +0100 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py Mon Aug 13 22:54:55 2007 +0100 @@ -27,8 +27,24 @@ proc = None def __init__(self, params): + self.status = 0 transcoder.Transcoder.__init__(self, params) self.opts = [] + self.opts.append (self.gmencoder_path) + self.opts.append ("-d") + self._parser_params () + + outfile = self.params_first("outfile", "") + + if outfile != "": + path = os.path.join(sys.path[0], ".transcoded", outfile) + self._insert_param("-o", "file://%s" % path) + else: + self._insert_param ("-o", "fd://%d" % outfd.fileno()) + self.opts.append ("-c") + + cmd = " ".join(self.opts) + # __init__() def _insert_param (self, name, value): @@ -50,21 +66,6 @@ # _parse_params def start(self, outfd): - self.status = 0 - self.opts.append (self.gmencoder_path) - self.opts.append ("-d") - self._parser_params () - - outfile = self.params_first("outfile", "") - - if outfile != "": - path = os.path.join(sys.path[0], ".transcoded", outfile) - self._insert_param("-o", "file://%s" % path) - else: - self._insert_param ("-o", "fd://%d" % outfd.fileno()) - self.opts.append ("-c") - - cmd = " ".join(self.opts) self.log.info(self.tid, "GMencoder: %s" % cmd) try: @@ -75,23 +76,18 @@ outfd.write("Error: GMencoder: %s" % e) return False - if outfile: - outfd.write("OK ") - try: while (self.proc and self.proc.poll() == None): r, w, x = select.select([self.proc.stdout], [], [], 0) if self.proc.stdout in r: progress = self.proc.stdout.readline() if (progress.find ("PROGRESS") >= 0): - self.log.info (self.tid, "%s" % progress) self.status = progress.split (":")[1] except Exception, e: self.log.error(self.tid, "Problems handling data: %s" % e) return False self.status = 100; - self.log.info(self.tid, "OK: Done") return True # start() @@ -100,7 +96,6 @@ if self.proc: self.log.info(self.tid, "Stopped GMencoder plugin") try: - self.proc.stdin.write("QUIT\n") os.kill(self.proc.pid, signal.SIGKILL) self.proc.wait() except Exception, e: @@ -109,4 +104,10 @@ self.proc = None # stop() + def get_progress(self): + return self.status + + def get_lenght(self): + return -1 + # TranscoderGMencoder