1.1 --- a/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Mon May 14 15:05:42 2007 +0100
1.2 +++ b/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Tue May 15 14:41:04 2007 +0100
1.3 @@ -3,6 +3,7 @@
1.4 import signal
1.5 import subprocess
1.6 import time
1.7 +import fcntl
1.8
1.9 import lib.utils as utils
1.10 import lib.server as server
1.11 @@ -224,6 +225,7 @@
1.12 # _start_outfile()
1.13
1.14 def _start(self, outfd):
1.15 + # Play a file on disk or DVD
1.16 if not self._run_mencoder(output=subprocess.PIPE):
1.17 return False
1.18
1.19 @@ -253,42 +255,37 @@
1.20
1.21 try:
1.22 self.gmyth = subprocess.Popen(opts, stdout=subprocess.PIPE,
1.23 + stderr=subprocess.PIPE,
1.24 close_fds=True)
1.25 except Exception, e:
1.26 self.log.error("Error executing gmyth-cat: %s" % e)
1.27 return False
1.28
1.29 + err = self.gmyth.stderr
1.30 +
1.31 if not self._run_mencoder(input=self.gmyth.stdout,
1.32 output=subprocess.PIPE):
1.33 return False
1.34
1.35 - show_loading = 0
1.36 - show = True
1.37 -
1.38 - #n800 150000 and 1000
1.39 + if kind == "f":
1.40 + partial = 0
1.41 + size = err.read(20).split("\n")[0].split("Size:")[1]
1.42 + self.log.debug("Size of file: %s" % size)
1.43 + flags = fcntl.fcntl (err, fcntl.F_GETFL, 0) | os.O_NONBLOCK
1.44 + fcntl.fcntl(err, fcntl.F_SETFL, flags)
1.45
1.46 try:
1.47 while self.proc and self.proc.poll() == None:
1.48 -
1.49 - r, w, x = select([self.proc.stdout], [], [], 0)
1.50 + r, w, x = select([err, self.proc.stdout], [], [], 0)
1.51 if self.proc.stdout in r:
1.52 d = self.proc.stdout.read(4096)
1.53 outfd.write(d)
1.54 - # self.log.debug("Sending tv data: %d" % show_loading)
1.55 - # if show_loading > 150000 and show:
1.56 - # self.log.debug("Disabling loading video")
1.57 - # show = False
1.58
1.59 - #elif show_loading % 10000 == 0 and show:
1.60 - # show_loading += 1
1.61 - # d = open("loading.mpg")
1.62 - # outfd.write(d.read())
1.63 - # self.log.debug("Sendind loading video: %d" % show_loading)
1.64 + if err in r and kind == "f":
1.65 + partial = err.read(50).split("\n")[-2]
1.66 + if partial != "":
1.67 + utils.progress_bar(self.log, int(partial), int(size), 50)
1.68
1.69 - #else:
1.70 - # show_loading += 1
1.71 -
1.72 - #self.log.debug("SHOW_LOADING: %d" % show_loading)
1.73
1.74 except Exception, e:
1.75 self.log.error("Problems handling data: %s" % e)