Форум сайта python.su
Есть такая программка - из сети получает поток и воспроизводит его в mplayer.
import socket import subprocess import threading def server(): cmdline = 'mplayer -fps 30 -cache 1024 -' player = subprocess.Popen(cmdline.split(), stdin=subprocess.PIPE) while True: data = client.recv(1024) player.stdin.write(data) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('0.0.0.0', 60000)) s.listen(1) client, addr = s.accept() thread = threading.Thread(target=server) thread.daemon = True thread.start()
import wx import socket import MplayerCtrl as mpc import threading class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY) self.mpc = mpc.MplayerCtrl(self, wx.ID_ANY, 'mplayer',mplayer_args=('-cache','1024','-fps','30','-')) self.Show() def server(): while True: data = client.recv(1024) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('0.0.0.0', 60000)) s.listen(1) client, addr = s.accept() application = wx.App() Main = Frame() thread = threading.Thread(target=server) thread.daemon = True thread.start() application.MainLoop()
Отредактировано jony_77 (Сен. 23, 2014 11:57:23)
Офлайн