Fix YouTube relay instabile e timer LIVE a zero in app

ffmpeg: probesize/analyzeduration su _air, restart più rapido e avvio relay
al go_live. App: sincronizza started_at dal server e fallback al passaggio live.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-04 08:56:59 +02:00
parent 841e99c775
commit fde1213ca5
4 changed files with 30 additions and 3 deletions

View File

@@ -56,10 +56,13 @@ module Streams
return if session.stream_key.blank?
return unless Streams::OverlayRelay.running?(session.id)
pid = pid_for(session.id)
clear_pid(session.id) if pid.present? && !process_alive?(pid.to_i)
return if running?(session.id)
last_restart = redis.get(restart_debounce_key(session.id)).to_i
return if last_restart.positive? && (Time.now.to_i - last_restart) < 20
return if last_restart.positive? && (Time.now.to_i - last_restart) < 5
start(session)
redis.set(restart_debounce_key(session.id), Time.now.to_i, ex: 300)
@@ -75,6 +78,7 @@ module Streams
[
"ffmpeg", "-nostdin", "-hide_banner", "-loglevel", "warning",
"-fflags", "+genpts+discardcorrupt", "-use_wallclock_as_timestamps", "1",
"-analyzeduration", "10000000", "-probesize", "10000000",
"-rw_timeout", "15000000",
"-i", intake,
"-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=48000",