1.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Tue May 29 21:24:48 2007 +0100
1.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Wed May 30 23:14:38 2007 +0100
1.3 @@ -14,6 +14,7 @@
1.4
1.5 import lib.utils as utils
1.6 import lib.server as server
1.7 +import lib.file_handler as files
1.8 import plugins.transcoders.mencoder_lib.mythtv as mythtv
1.9
1.10 from select import select
1.11 @@ -120,6 +121,11 @@
1.12 self._arg_append(args, self._setup_video())
1.13
1.14 self._arg_append(args, "-really-quiet")
1.15 +
1.16 + if self.args["outfile"] != "-":
1.17 + self.args["outfile"] = ".transcoded/%s" % (
1.18 + os.path.basename(self.args["outfile"]))
1.19 +
1.20 self._arg_append(args, "-o %s" % self.args["outfile"])
1.21 self._arg_append(args, "2>%s" % os.devnull)
1.22 # _setup_args()
1.23 @@ -160,7 +166,7 @@
1.24 self._setup_filename()
1.25 self._setup_mencoder_opts(self.mencoder_opts)
1.26 except Exception, e:
1.27 - self.log.error(self.tid, e)
1.28 + self.log.error(self.tid, "Error: %s" % e)
1.29 # __init__()
1.30
1.31
1.32 @@ -177,15 +183,15 @@
1.33 def _start_outfile(self, outfd):
1.34 finished = False
1.35
1.36 - # fix this (not necessary)
1.37 - outfd.write("OK")
1.38 -
1.39 # Configuring stdin
1.40 try:
1.41 - _stdin = open(self.args["input"])
1.42 - size = int(os.path.getsize(self.args["input"]))
1.43 + filename = self.args["input"].split("://")[1]
1.44 + _stdin = open(filename)
1.45 + size = int(os.path.getsize(filename))
1.46 except Exception, e:
1.47 - self.log.error(self.tid, "Mencoder stdin setup error: %s" % e)
1.48 + self.log.error(self.tid, "Error: Mencoder stdin"\
1.49 + " setup error: %s" % e)
1.50 + outfd.write("Error: Mencoder stdin setup error: %s" %e)
1.51 return False
1.52
1.53 self.status = 0
1.54 @@ -207,8 +213,7 @@
1.55 os.write(stdw, data_in)
1.56 total_read += 4096
1.57 d = stdout.read(4096)
1.58 - self.status = utils.progress_bar(self.log,
1.59 - int(total_read),
1.60 + self.status = utils.progress_bar(int(total_read),
1.61 int(size), 50)
1.62 else:
1.63 finished = True
1.64 @@ -218,11 +223,12 @@
1.65 d = stdout.read(4096)
1.66
1.67 except Exception, e:
1.68 - self.log.error(self.tid, "Problems handling data: %s" % e)
1.69 + self.log.error(self.tid, "Error: %s" % e)
1.70 self.stop()
1.71 return False
1.72
1.73 - self.log.info(self.tid, "%s: Finished sending data to client" % repr(self))
1.74 + files.TranscodedFile("", self.args)
1.75 + self.log.info(self.tid, "OK: Done")
1.76 return True
1.77 # _start_outfile()
1.78
1.79 @@ -236,10 +242,10 @@
1.80 d = self.proc.stdout.read(1024)
1.81 outfd.write(d)
1.82 except Exception, e:
1.83 - self.log.error(self.tid, "Problems handling data: %s" % e)
1.84 + self.log.error(self.tid, "Error: %s" % e)
1.85 return False
1.86
1.87 - self.log.info(self.tid, "%s: Finished sending data to client" % repr(self))
1.88 + self.log.info(self.tid, "OK: Done")
1.89 return True
1.90 # _start()
1.91
1.92 @@ -248,7 +254,7 @@
1.93 self.proc = subprocess.Popen(self.mencoder_opts, stdin=input,
1.94 stdout=output, close_fds=True)
1.95 except Exception, e:
1.96 - self.log.error(self.tid, "Error executing mencoder: %s" % e)
1.97 + self.log.error(self.tid, "Error: Mencoder: %s" % e)
1.98 return False
1.99
1.100 return True
1.101 @@ -275,7 +281,8 @@
1.102 self.stop()
1.103
1.104 if not ret:
1.105 - self.log.error(self.tid, "Problems while starting streaming.")
1.106 + self.log.error(self.tid, "Error: Problems while "\
1.107 + "starting streaming.")
1.108
1.109 return ret
1.110 # start()