[svn r819] video bitrate changed from 600kbps to 300kbps. Frame rate default value set to 10fps
3 __author__ = "Renato Filho"
4 __author_email__ = "renato.filho@indt.org.br"
18 import lib.utils as utils
19 import lib.server as server
20 import lib.transcoder as transcoder
22 __all__ = ("TranscoderGMencoder",)
24 class TranscoderGMencoder(transcoder.Transcoder):
25 gmencoder_path = utils.which("gmencoder")
30 def __init__(self, params):
32 transcoder.Transcoder.__init__(self, params)
34 self.opts.append (self.gmencoder_path)
35 self.opts.append ("-d")
36 self._parser_params ()
40 def _insert_param (self, name, value):
42 self.opts.append(name)
43 self.opts.append(value)
45 def _parser_params (self):
46 self._insert_param("-i", \
47 "%s://%s" % (self.params_first("type", "file"),
48 self.params_first("uri", "")))
49 self._insert_param("--video-encode", self.params_first("ve", "ffenc_mpeg1video"))
50 self._insert_param("--video-opts", "bitrate=300000,pass=512,quantizer=0.01,quant-type=1")
51 #self._insert_param("--video-fps", self.params_first("fps", ""))
52 self._insert_param("--video-fps", self.params_first("fps", "10"))
53 self._insert_param("--video-width", self.params_first("width", "320"))
54 self._insert_param("--video-height", self.params_first("height", "240"))
55 self._insert_param("--audio-rate", "32000")
56 self._insert_param("--audio-encode", self.params_first("ae", ""))
59 def start(self, outfd):
60 outfile = self.params_first("outfile", "")
63 path = os.path.join(sys.path[0], ".transcoded", outfile)
64 self._insert_param("-o", "file://%s" % path)
66 self._insert_param ("-o", "fd://%d" % outfd.fileno())
67 self.opts.append ("-c")
69 cmd = " ".join(self.opts)
70 self.log.info(self.tid, "GMencoder: %s" % cmd)
73 self.proc = subprocess.Popen(self.opts, stdin=subprocess.PIPE,
74 stdout=subprocess.PIPE)
76 self.log.error(self.tid, "Error: executing GMencoder: %s" % e)
77 outfd.write("Error: GMencoder: %s" % e)
83 p.register (outfd, select.POLLNVAL | select.POLLERR | select.POLLHUP | select.POLLIN )
84 while (self.proc and self.proc.poll() == None):
85 r, w, x = select.select([self.proc.stdout], [], [], 1)
86 if self.proc.stdout in r:
87 progress = self.proc.stdout.readline()
88 if (progress.find ("PROGRESS") >= 0):
89 self.status = progress.split (":")[1]
90 elif (progress.find ("Erro") >= 0):
95 print "Lost Connection"
100 self.log.error(self.tid, "Problems handling data: %s" % e)
114 self.log.info(self.tid, "Stopped GMencoder plugin")
116 os.kill(self.proc.pid, signal.SIGKILL)
124 def get_progress(self):
127 def get_lenght(self):
130 # TranscoderGMencoder