fix: check both _ffmpeg_proc and _srt_ffmpeg_proc in stream.mp3 route
This commit is contained in:
parent
20bedad639
commit
0ec02507b3
12
server.py
12
server.py
|
|
@ -627,12 +627,20 @@ def setup_shared_routes(app, index_file='index.html'):
|
||||||
# For MP3 input (e.g. Qt client) chunks are distributed directly — no ffmpeg needed.
|
# For MP3 input (e.g. Qt client) chunks are distributed directly — no ffmpeg needed.
|
||||||
is_mp3_direct = broadcast_state.get('is_mp3_input', False)
|
is_mp3_direct = broadcast_state.get('is_mp3_input', False)
|
||||||
if not is_mp3_direct:
|
if not is_mp3_direct:
|
||||||
|
def _active_transcoder():
|
||||||
|
"""Return True if either the WebSocket or SRT ffmpeg transcoder is alive."""
|
||||||
|
if _ffmpeg_proc is not None and _ffmpeg_proc.poll() is None:
|
||||||
|
return True
|
||||||
|
if _srt_ffmpeg_proc is not None and _srt_ffmpeg_proc.poll() is None:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
waited = 0.0
|
waited = 0.0
|
||||||
while (_ffmpeg_proc is None or _ffmpeg_proc.poll() is not None) and waited < 5.0:
|
while not _active_transcoder() and waited < 5.0:
|
||||||
eventlet.sleep(0.5)
|
eventlet.sleep(0.5)
|
||||||
waited += 0.5
|
waited += 0.5
|
||||||
|
|
||||||
if _ffmpeg_proc is None or _ffmpeg_proc.poll() is not None:
|
if not _active_transcoder():
|
||||||
return Response(b'', status=503, content_type='audio/mpeg', headers={
|
return Response(b'', status=503, content_type='audio/mpeg', headers={
|
||||||
'Retry-After': '3',
|
'Retry-After': '3',
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue