mirror of
https://github.com/MichaByte/OnBoard-Live.git
synced 2025-12-06 05:33:40 -05:00
kinda working
This commit is contained in:
parent
e468e0b9ab
commit
35c2a98835
6 changed files with 36 additions and 17 deletions
|
|
@ -2,9 +2,9 @@ import subprocess
|
|||
import time
|
||||
import requests
|
||||
|
||||
time.sleep(5)
|
||||
time.sleep(10)
|
||||
|
||||
active_stream = requests.get("http://backend:8000/api/v1/active_stream").text
|
||||
active_stream = requests.get("http://backend:8000/api/v1/active_stream").text.replace('"', '')
|
||||
print(active_stream)
|
||||
|
||||
old_active_stream = active_stream
|
||||
|
|
@ -12,19 +12,18 @@ old_active_stream = active_stream
|
|||
proc = None
|
||||
|
||||
if active_stream != "":
|
||||
proc = subprocess.Popen(["/bin/ffmpeg", "-re", "-i", f"rtmp://mediamtx:1935/{active_stream}", "-c:a copy", "rtmp://live-stream:1936/active-input"])
|
||||
proc = subprocess.Popen(["ffmpeg", "-re", "-i", f"rtmp://mediamtx:1935/{active_stream}", "-c:a", "libmp3lame", "-f", "flv", "rtmp://host.containers.internal:1936/active-input"])
|
||||
else:
|
||||
proc = subprocess.Popen(["/bin/ffmpeg", "-i", "anullsrc", "-c:a copy", "rtmp://live-stream:1936/active-input"])
|
||||
|
||||
proc = subprocess.Popen(["ffmpeg", "-f", "lavfi", "-i", "anullsrc", "-c:a", "libmp3lame", "-f", "flv", "rtmp://host.containers.internal:1936/active-input"])
|
||||
|
||||
while True:
|
||||
time.sleep(3)
|
||||
active_stream = requests.get("http://backend:8000/api/v1/active_stream").text
|
||||
active_stream = requests.get("http://backend:8000/api/v1/active_stream").text.replace('""', '')
|
||||
if old_active_stream is not active_stream:
|
||||
if proc:
|
||||
proc.terminate()
|
||||
if active_stream != "":
|
||||
proc = subprocess.Popen(["/bin/ffmpeg", "-re", "-i", f"rtmp://mediamtx:1935/{active_stream}", "-c:a copy", "rtmp://live-stream:1936/active-input"])
|
||||
proc = subprocess.Popen(["ffmpeg", "-re", "-i", f"rtmp://mediamtx:1935/{active_stream}", "-c:a", "libmp3lame", "-f", "flv", "rtmp://host.containers.internal:1936/active-input"])
|
||||
else:
|
||||
proc = subprocess.Popen(["/bin/ffmpeg", "-i", "anullsrc", "-c:a copy", "rtmp://live-stream:1936/active-input"])
|
||||
proc = subprocess.Popen(["ffmpeg", "-f", "lavfi", "-i", "anullsrc", "-c:a", "libmp3lame", "-f", "flv", "rtmp://host.containers.internal:1936/active-input"])
|
||||
old_active_stream = active_stream
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue