diff -r 8bd1033f8bf6 -r 76a3f315ef42 gmyth-stream/server/0.2/plugins/transcoders/mencoder.py --- a/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Mon May 14 15:05:42 2007 +0100 +++ b/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Tue May 15 14:41:04 2007 +0100 @@ -3,6 +3,7 @@ import signal import subprocess import time +import fcntl import lib.utils as utils import lib.server as server @@ -224,6 +225,7 @@ # _start_outfile() def _start(self, outfd): + # Play a file on disk or DVD if not self._run_mencoder(output=subprocess.PIPE): return False @@ -253,42 +255,37 @@ try: self.gmyth = subprocess.Popen(opts, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, close_fds=True) except Exception, e: self.log.error("Error executing gmyth-cat: %s" % e) return False + err = self.gmyth.stderr + if not self._run_mencoder(input=self.gmyth.stdout, output=subprocess.PIPE): return False - show_loading = 0 - show = True - - #n800 150000 and 1000 + if kind == "f": + partial = 0 + size = err.read(20).split("\n")[0].split("Size:")[1] + self.log.debug("Size of file: %s" % size) + flags = fcntl.fcntl (err, fcntl.F_GETFL, 0) | os.O_NONBLOCK + fcntl.fcntl(err, fcntl.F_SETFL, flags) try: while self.proc and self.proc.poll() == None: - - r, w, x = select([self.proc.stdout], [], [], 0) + r, w, x = select([err, self.proc.stdout], [], [], 0) if self.proc.stdout in r: d = self.proc.stdout.read(4096) outfd.write(d) - # self.log.debug("Sending tv data: %d" % show_loading) - # if show_loading > 150000 and show: - # self.log.debug("Disabling loading video") - # show = False - #elif show_loading % 10000 == 0 and show: - # show_loading += 1 - # d = open("loading.mpg") - # outfd.write(d.read()) - # self.log.debug("Sendind loading video: %d" % show_loading) + if err in r and kind == "f": + partial = err.read(50).split("\n")[-2] + if partial != "": + utils.progress_bar(self.log, int(partial), int(size), 50) - #else: - # show_loading += 1 - - #self.log.debug("SHOW_LOADING: %d" % show_loading) except Exception, e: self.log.error("Problems handling data: %s" % e)