I have 2 RTSP streams, I would like to change between them each minute and I would like to write the result into the same file (streaming.m3u8) and I would like embed HTML video tag. But the video change is not working.
import ffmpeg
import schedule
import time
def stream_1():
packet_size = 4096
process = (
ffmpeg
.input('rtsp://....')
.output('streaming.m3u8', hls_time=3, hls_wrap=10)
.run_async(pipe_stdout=True)
)
while process.poll() is None:
packet = process.stdout.read(packet_size)
try:
tcp_socket.send(packet)
except socket.error:
process.stdout.close()
process.wait()
break
def stream_2():
packet_size = 4096
process = (
ffmpeg
.input('rtsp://....')
.output('streaming.m3u8', hls_time=3, hls_wrap=10)
.run_async(pipe_stdout=True)
)
while process.poll() is None:
packet = process.stdout.read(packet_size)
try:
tcp_socket.send(packet)
except socket.error:
process.stdout.close()
process.wait()
break
schedule.every(1).minutes.do(stream_1)
schedule.every(2).minutes.do(stream_2)