# HG changeset patch # User morphbr # Date 1175717923 -3600 # Node ID 9900800a8dd6270546d6eed025f14ea3d379224b # Parent 7a0c3906dce2c8572783c41f14e00ffdadae62ce [svn r504] Gmyth-Streamer: mencoder stdout bug fix (Chenca's bug) diff -r 7a0c3906dce2 -r 9900800a8dd6 gmyth-stream/server/plugins/comm/tcp.py --- a/gmyth-stream/server/plugins/comm/tcp.py Wed Apr 04 18:05:44 2007 +0100 +++ b/gmyth-stream/server/plugins/comm/tcp.py Wed Apr 04 21:18:43 2007 +0100 @@ -2,7 +2,7 @@ import time import socket -class Server: +class Server(object): def __init__(self, config): self.host = '' diff -r 7a0c3906dce2 -r 9900800a8dd6 gmyth-stream/server/plugins/media/mencoder.py --- a/gmyth-stream/server/plugins/media/mencoder.py Wed Apr 04 18:05:44 2007 +0100 +++ b/gmyth-stream/server/plugins/media/mencoder.py Wed Apr 04 21:18:43 2007 +0100 @@ -46,17 +46,17 @@ self.kind = "file" self.args += " %s -mf fps=%s -of %s %s"\ " -ovc lavc -lavcopts vcodec=%s:vbitrate=%s -vf scale=%s:%s"\ - " -o %s 1> /dev/null 2> /dev/null" % ( + " -really-quiet -o %s" % ( self.filename, self.fps, self.mux, audio, self.vcodec, self.vbitrate, self.width, self.height, self.fifo) elif opt == "dvd": self.kind = "dvd" self.args += " dvd://%s -alang %s -vf scale=%s:%s %s"\ - " -of %s -ovc lavc -lavcopts vcodec=%s:vbitrate=%s -o %s"\ - " -ofps %s 1> /dev/null 2> /dev/null" % ( + " -of %s -ovc lavc -lavcopts vcodec=%s:vbitrate=%s"\ + " -ofps %s -really-quiet -o %s" % ( self.filename, self.language, self.width, self.height, audio, - self.mux, self.vcodec, self.vbitrate, self.fifo, self.fps) + self.mux, self.vcodec, self.vbitrate, self.fps, self.fifo) elif opt == "local": self.mplayer = os.popen("which mplayer").read().strip() @@ -97,7 +97,21 @@ self.height = height self.port = int(port) - self.fifo = self.config.get("Mencoder", "fifo_path") + + self.path = self.config.get("Mencoder", "path") + a, b = os.popen2(self.path) + version = b.read().split("MEncoder ")[1].split(" (C)")[0].split("-")[-1] + + if version > "4.1.1": self.mencoder_old = False + else: self.mencoder_old = True + + a.close() + b.close() + + if self.mencoder_old: + self.fifo = self.config.get("Mencoder", "fifo_path") + else: + self.fifo = "-" self.args = "" self.kind = "" @@ -110,8 +124,6 @@ # good one: /tmp/dvb.mpg avi mpeg4 400 25 mp3lame 192 320 240 5000 file #4 mpeg mpeg1video 400 25 mp3lame 192 400 240 5000 language=en local dvd - self.path = self.config.get("Mencoder", "path") - if self.socket != None: del(self.socket) @@ -125,16 +137,21 @@ def play(self): - try: - os.mkfifo(self.fifo) - except: - lib.log("Fifo already exists") + if self.mencoder_old: + try: + os.mkfifo(self.fifo) + except: + lib.log("Fifo already exists") + lib.log("Starting Mencoder: %s %s" % (self.path, self.args) ) # exec Mencoder - self.mencoder_pid = Popen(self.path + self.args, shell=True) - - fifo = open(self.fifo) + if self.mencoder_old: + self.mencoder_pid = Popen(self.path + self.args, shell=True) + fifo = open(self.fifo) + else: + self.path += self.args + pin, self.pout = os.popen2(self.path) self.child_pid = os.fork() @@ -142,7 +159,8 @@ conn,addr= self.socket.accept() lib.log("Sending Data to client: %s" % addr[0]) - data = fifo.read(1024) + data = self.pout.read(1024) + conn.settimeout(5) retry = 0 @@ -159,7 +177,7 @@ lib.log("Socket error (maybe timeout ?)") retry += 1 - data = fifo.read(1024) + data = self.pout.read(1024) if retry < 5: lib.log("Finished sending Data to client: %s" % addr[0]) @@ -171,7 +189,10 @@ def stop(self): try: - os.kill(self.mencoder_pid.pid + 1, signal.SIGKILL) + if self.mplayer_old: + os.kill(self.mencoder_pid.pid + 1, signal.SIGKILL) + else: + self.pout.close() self.mplayer = None except: lib.log("Trying to stop before playing...") diff -r 7a0c3906dce2 -r 9900800a8dd6 gmyth-stream/server/stream.conf --- a/gmyth-stream/server/stream.conf Wed Apr 04 18:05:44 2007 +0100 +++ b/gmyth-stream/server/stream.conf Wed Apr 04 21:18:43 2007 +0100 @@ -19,5 +19,5 @@ [Mencoder] -path = /usr/local/bin/mencoder +path = /usr/bin/mencoder fifo_path = /tmp/teste