[svn r663] Added verification to GMYTH_FILE_READ_NEXT_PROG_CHAIN return values.
6 import lib.utils as utils
7 import lib.server as server
9 __all__ = ("TranscoderGMencoder",)
11 class TranscoderGMencoder(server.Transcoder):
12 gmencoder_path = utils.which("gmencoder")
17 def __init__(self, params):
18 server.Transcoder.__init__(self, params)
22 def _insert_param (self, name, value):
24 self.opts.append(name)
25 self.opts.append(value)
27 def _parser_params (self):
28 self._insert_param("-i", \
29 "%s://%s" % (self.params_first("uri_prefix", "file"), self.params_first("uri_path", "")))
30 self._insert_param("--video-encode", self.params_first("ve", ""))
31 self._insert_param("--video-opts", "bitrate=200,pass=2,quantizer=5")
32 self._insert_param("--video-fps", self.params_first("fps", ""))
33 self._insert_param("--video-width", self.params_first("width", ""))
34 self._insert_param("--video-height", self.params_first("height", ""))
35 self._insert_param("--audio-rate", "32000")
36 self._insert_param("--audio-encode", self.params_first("ae", ""))
39 def start(self, outfd):
40 self.opts.append (self.gmencoder_path)
41 self._parser_params ()
42 self._insert_param ("-o", "fd://%d" % outfd.fileno())
44 cmd = " ".join(self.opts)
45 self.log.info ("GMencoder: %s", cmd)
48 self.proc = subprocess.Popen(self.opts, stdin=subprocess.PIPE)
50 self.log.error("Error executing GMencoder: %s" % e)
56 self.log.error("Problems handling data: %s" % e)
65 self.log.info ("STOPed GMencoder plugin")
67 self.proc.stdin.write ("QUIT\n")