fix: check both _ffmpeg_proc and _srt_ffmpeg_proc in stream.mp3 route

This commit is contained in:
ComputerTech 2026-04-04 14:35:35 +01:00
parent 20bedad639
commit 0ec02507b3
1 changed files with 10 additions and 2 deletions

View File

@ -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.
is_mp3_direct = broadcast_state.get('is_mp3_input', False)
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
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)
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={
'Retry-After': '3',
'Access-Control-Allow-Origin': '*',