author | morphbr |
Thu May 17 14:07:27 2007 +0100 (2007-05-17) | |
branch | trunk |
changeset 682 | 367d791aeb57 |
permissions | -rw-r--r-- |
morphbr@565 | 1 |
import os |
morphbr@565 | 2 |
import sys |
morphbr@565 | 3 |
import time |
morphbr@565 | 4 |
import socket |
morphbr@565 | 5 |
|
morphbr@565 | 6 |
|
morphbr@565 | 7 |
if len(sys.argv) < 2: |
morphbr@565 | 8 |
HOST = 'localhost' |
morphbr@565 | 9 |
PORT = 50000 |
morphbr@565 | 10 |
elif len(sys.argv) == 2: |
morphbr@565 | 11 |
HOST = sys.argv[1] |
morphbr@565 | 12 |
PORT = 50000 |
morphbr@565 | 13 |
else: |
morphbr@565 | 14 |
HOST = sys.argv[1] |
morphbr@565 | 15 |
PORT = int(sys.argv[2]) |
morphbr@565 | 16 |
|
morphbr@565 | 17 |
socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) |
morphbr@565 | 18 |
socket.settimeout(10) |
morphbr@565 | 19 |
|
morphbr@565 | 20 |
try: |
morphbr@565 | 21 |
socket.connect( (HOST,PORT) ) |
morphbr@565 | 22 |
except: |
morphbr@565 | 23 |
print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT) |
morphbr@565 | 24 |
sys.exit(-1) |
morphbr@565 | 25 |
|
morphbr@565 | 26 |
|
morphbr@565 | 27 |
mplayer = os.popen("which mplayer").read().strip() |
morphbr@565 | 28 |
mplayer += " -idx - -vo x11 1> /dev/null" |
morphbr@565 | 29 |
pin, pout = os.popen2(mplayer) |
morphbr@565 | 30 |
|
morphbr@565 | 31 |
#teste = open("teste.avi", "w") |
morphbr@565 | 32 |
|
morphbr@565 | 33 |
data = socket.recv(4096) |
morphbr@565 | 34 |
i = 0 |
morphbr@565 | 35 |
|
morphbr@565 | 36 |
while (data != ""): |
morphbr@565 | 37 |
pin.write(data) |
morphbr@565 | 38 |
#teste.write(data) |
morphbr@565 | 39 |
data = socket.recv(4096) |
morphbr@565 | 40 |
#if (i == 500): |
morphbr@565 | 41 |
# socket.send("OK") |
morphbr@565 | 42 |
i += 1 |
morphbr@565 | 43 |
|
morphbr@565 | 44 |
pin.close() |
morphbr@565 | 45 |
socket.close() |
morphbr@565 | 46 |
#teste.close() |
morphbr@565 | 47 |
|
morphbr@565 | 48 |
# from select import select |
morphbr@565 | 49 |
# r, w, x = select([pout], []. [], 0) |
morphbr@565 | 50 |
# if pout in r: |
morphbr@565 | 51 |
# pout.read(32) |