# HG changeset patch # User renatofilho # Date 1179337570 -3600 # Node ID 4e623a4274a1e85b66da345ba19dcc38a8de1448 # Parent a05b421242e4ea30500f92714edd88625520cb53 [svn r678] implemented progress on gmencoder plugin diff -r a05b421242e4 -r 4e623a4274a1 gmyth-stream/server/0.2/plugins/transcoders/gmencoder.py --- a/gmyth-stream/server/0.2/plugins/transcoders/gmencoder.py Wed May 16 18:45:29 2007 +0100 +++ b/gmyth-stream/server/0.2/plugins/transcoders/gmencoder.py Wed May 16 18:46:10 2007 +0100 @@ -2,6 +2,9 @@ import shlex import signal import subprocess +import time + +import select import lib.utils as utils import lib.server as server @@ -26,7 +29,7 @@ def _parser_params (self): self._insert_param("-i", \ - "%s://%s" % (self.params_first("uri_prefix", "file"), self.params_first("uri_path", ""))) + "%s://%s" % (self.params_first("type", "file"), self.params_first("uri", ""))) self._insert_param("--video-encode", self.params_first("ve", "")) self._insert_param("--video-opts", "bitrate=200,pass=2,quantizer=5") self._insert_param("--video-fps", self.params_first("fps", "")) @@ -45,13 +48,19 @@ self.log.info ("GMencoder: %s", cmd) try: - self.proc = subprocess.Popen(self.opts, stdin=subprocess.PIPE) + self.proc = subprocess.Popen(self.opts, stdin=subprocess.PIPE, stdout=subprocess.PIPE) except Exception, e: self.log.error("Error executing GMencoder: %s" % e) return False try: - self.proc.wait() + 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.status = progress.split (":")[1] + self.log.info ("Process exit") except Exception, e: self.log.error("Problems handling data: %s" % e) return False @@ -62,7 +71,7 @@ def stop(self): if self.proc: - self.log.info ("STOPed GMencoder plugin") + self.log.info ("STOPED GMencoder plugin") try: self.proc.stdin.write ("QUIT\n") except Exception, e: