[svn r951] gmyth now is 0.8.1. Added methods epg_is_connected() and scheduler_is_connected()
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", ""))
50 self._insert_param("--video-opts", self.params_first ("video-opts", ""))
51 self._insert_param("--video-fps", self.params_first("fps", ""))
52 self._insert_param("--video-width", self.params_first("width", ""))
53 self._insert_param("--video-height", self.params_first("height", ""))
54 self._insert_param("--audio-encode", self.params_first("ae", ""))
55 self._insert_param("--audio-opts", self.params_first ("audio-opts", ""))
56 self._insert_param("--mux-element", self.params_first("mux", ""))
57 self._insert_param("--audio-rate", self.params_first("audio-rate", ""))
60 def start(self, outfd):
61 outfile = self.params_first("outfile", "")
64 path = os.path.join(utils.config.get_transcoded_location(), outfile)
65 self._insert_param("-o", "file://%s" % path)
67 self._insert_param ("-o", "fd://%d" % outfd.fileno())
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)
80 self.log.error(self.tid, "Error: executing GMencoder: %s" % e)
81 outfd.write("Error: GMencoder: %s" % e)
87 p.register (outfd, select.POLLNVAL | select.POLLERR |
90 while (self.proc and self.proc.poll() == None):
91 r, w, x = select.select([self.proc.stdout], [], [], 1)
92 if self.proc.stdout in r:
93 progress = self.proc.stdout.readline()
94 if (progress.find ("PROGRESS") >= 0):
95 self.status = progress.split (":")[1]
96 elif (progress.find ("Erro") >= 0):
97 self.log.error(self.tid, "Detected problem @ gmencoder:"
107 self.log.info(self.tid, "* Lost connection *")
112 self.log.error(self.tid, "Problems handling data: %s" % e)
124 self.log.info(self.tid, "Stopped GMencoder plugin")
126 os.kill(self.proc.pid, signal.SIGKILL)
134 def get_progress(self):
137 def get_lenght(self):
140 # TranscoderGMencoder