#!/usr/bin/env python3 import sys oldexcepthook = sys.excepthook def newexcepthook(type,value,traceback): oldexcepthook(type,value,traceback) input("Press ENTER to quit.") sys.excepthook = newexcepthook import os p = os.path.join pUp = os.path.dirname s = False if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): s = os.path.realpath(sys.executable) else: s = os.path.realpath(__file__) sp = pUp(s) # script start import subprocess import socket bufferSize = 1000 serverAddr = ("127.0.0.1",12000) connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def main(): connection.settimeout(15) connection.connect(serverAddr) proc = subprocess.Popen([ "ffplay","-f","mpegts", "-i","-", "-fflags","nobuffer", "-flags","low_delay", "-infbuf","-fast","-framedrop" ],stdin=subprocess.PIPE) while True: data = connection.recv(bufferSize) proc.stdin.write(data) if __name__ == '__main__': main()