26 lines
610 B
Python
26 lines
610 B
Python
import subprocess
|
|
|
|
class Reciever:
|
|
|
|
def __init__(self, protocol: str, target: str) -> None:
|
|
self.protocol = protocol # should be 'tcp' or 'udp'
|
|
self.target = target
|
|
self.proc = None
|
|
|
|
def __del__(self) -> None:
|
|
self.stop()
|
|
|
|
def start(self):
|
|
# currently there is no direct ffplay support in the ffmpeg package
|
|
|
|
addr = self.protocol+ '://' + self.target + '?listen'
|
|
self.proc = subprocess.Popen(['ffplay', '-fflags', 'nobuffer', '-flags', 'low_delay', '-f', 'mpegts', addr])
|
|
|
|
def stop(self):
|
|
if self.proc:
|
|
self.proc.terminate()
|
|
self.proc.wait(1)
|
|
self.proc.kill()
|
|
self.proc = None
|
|
|