diff -r 3fbcd3d9b2d1 -r f5f7abc760aa gmyth-stream/server/0.3/plugins/transcoders/mencoder.py --- a/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Tue May 29 21:24:48 2007 +0100 +++ b/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Wed May 30 23:14:38 2007 +0100 @@ -14,6 +14,7 @@ import lib.utils as utils import lib.server as server +import lib.file_handler as files import plugins.transcoders.mencoder_lib.mythtv as mythtv from select import select @@ -120,6 +121,11 @@ self._arg_append(args, self._setup_video()) self._arg_append(args, "-really-quiet") + + if self.args["outfile"] != "-": + self.args["outfile"] = ".transcoded/%s" % ( + os.path.basename(self.args["outfile"])) + self._arg_append(args, "-o %s" % self.args["outfile"]) self._arg_append(args, "2>%s" % os.devnull) # _setup_args() @@ -160,7 +166,7 @@ self._setup_filename() self._setup_mencoder_opts(self.mencoder_opts) except Exception, e: - self.log.error(self.tid, e) + self.log.error(self.tid, "Error: %s" % e) # __init__() @@ -177,15 +183,15 @@ def _start_outfile(self, outfd): finished = False - # fix this (not necessary) - outfd.write("OK") - # Configuring stdin try: - _stdin = open(self.args["input"]) - size = int(os.path.getsize(self.args["input"])) + filename = self.args["input"].split("://")[1] + _stdin = open(filename) + size = int(os.path.getsize(filename)) except Exception, e: - self.log.error(self.tid, "Mencoder stdin setup error: %s" % e) + self.log.error(self.tid, "Error: Mencoder stdin"\ + " setup error: %s" % e) + outfd.write("Error: Mencoder stdin setup error: %s" %e) return False self.status = 0 @@ -207,8 +213,7 @@ os.write(stdw, data_in) total_read += 4096 d = stdout.read(4096) - self.status = utils.progress_bar(self.log, - int(total_read), + self.status = utils.progress_bar(int(total_read), int(size), 50) else: finished = True @@ -218,11 +223,12 @@ d = stdout.read(4096) except Exception, e: - self.log.error(self.tid, "Problems handling data: %s" % e) + self.log.error(self.tid, "Error: %s" % e) self.stop() return False - self.log.info(self.tid, "%s: Finished sending data to client" % repr(self)) + files.TranscodedFile("", self.args) + self.log.info(self.tid, "OK: Done") return True # _start_outfile() @@ -236,10 +242,10 @@ d = self.proc.stdout.read(1024) outfd.write(d) except Exception, e: - self.log.error(self.tid, "Problems handling data: %s" % e) + self.log.error(self.tid, "Error: %s" % e) return False - self.log.info(self.tid, "%s: Finished sending data to client" % repr(self)) + self.log.info(self.tid, "OK: Done") return True # _start() @@ -248,7 +254,7 @@ self.proc = subprocess.Popen(self.mencoder_opts, stdin=input, stdout=output, close_fds=True) except Exception, e: - self.log.error(self.tid, "Error executing mencoder: %s" % e) + self.log.error(self.tid, "Error: Mencoder: %s" % e) return False return True @@ -275,7 +281,8 @@ self.stop() if not ret: - self.log.error(self.tid, "Problems while starting streaming.") + self.log.error(self.tid, "Error: Problems while "\ + "starting streaming.") return ret # start()