morphbr@496: import os morphbr@496: import sys morphbr@496: import time morphbr@496: import socket morphbr@496: morphbr@496: morphbr@496: if len(sys.argv) < 2: morphbr@496: HOST = 'localhost' morphbr@516: PORT = 50000 morphbr@496: elif len(sys.argv) == 2: morphbr@496: HOST = sys.argv[1] morphbr@516: PORT = 50000 morphbr@496: else: morphbr@496: HOST = sys.argv[1] morphbr@496: PORT = int(sys.argv[2]) morphbr@496: morphbr@496: socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) morphbr@496: socket.settimeout(10) morphbr@496: morphbr@496: try: morphbr@496: socket.connect( (HOST,PORT) ) morphbr@496: except: morphbr@496: print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT) morphbr@496: sys.exit(-1) morphbr@496: morphbr@496: morphbr@496: mplayer = os.popen("which mplayer").read().strip() morphbr@516: mplayer += " -idx - -vo x11 1> /dev/null" morphbr@496: pin, pout = os.popen2(mplayer) morphbr@496: morphbr@516: #teste = open("teste.avi", "w") morphbr@496: morphbr@516: data = socket.recv(4096) morphbr@496: i = 0 morphbr@496: morphbr@496: while (data != ""): morphbr@496: pin.write(data) morphbr@496: #teste.write(data) morphbr@516: data = socket.recv(4096) morphbr@516: #if (i == 500): morphbr@516: # socket.send("OK") morphbr@496: i += 1 morphbr@496: morphbr@496: pin.close() morphbr@496: socket.close() morphbr@516: #teste.close() morphbr@496: morphbr@496: # from select import select morphbr@496: # r, w, x = select([pout], []. [], 0) morphbr@496: # if pout in r: morphbr@496: # pout.read(32)