32 lines
866 B
Python
32 lines
866 B
Python
import subprocess
|
|
from procmanager import ProcManager
|
|
|
|
class Reciever:
|
|
|
|
def __init__(self, protocol: str, target: str, disable_audio: bool) -> None:
|
|
self.protocol = protocol # should be 'tcp' or 'udp'
|
|
self.target = target
|
|
self.disable_audio = disable_audio
|
|
self.process_manager = ProcManager()
|
|
|
|
def __del__(self) -> None:
|
|
self.stop()
|
|
|
|
def start(self):
|
|
# currently there is no direct ffplay support in the ffmpeg package
|
|
|
|
args = ['ffplay', '-hide_banner', '-loglevel', 'error', '-fflags', 'nobuffer', '-flags', 'low_delay', '-f', 'mpegts']
|
|
|
|
if self.disable_audio:
|
|
args.append('-an')
|
|
|
|
# the address
|
|
args.append(self.protocol+ '://' + self.target + '?listen')
|
|
|
|
proc = subprocess.Popen(args, encoding='utf-8', shell=False, text=True, stderr=subprocess.PIPE)
|
|
self.process_manager.start(proc)
|
|
|
|
def stop(self):
|
|
self.process_manager.stop()
|
|
|