Improve FFmpeg startup speed and stream resilience

This commit is contained in:
Trevor Mears
2026-01-01 11:52:47 -08:00
parent ec9a6bcc23
commit 9fb8df7255
2 changed files with 15 additions and 4 deletions
+10 -2
View File
@@ -26,10 +26,15 @@ router.get('/', (req, res) => {
const args = [
'-hide_banner',
'-loglevel', 'warning',
// Error resilience: discard corrupt packets, generate timestamps
'-fflags', '+genpts+discardcorrupt+igndts',
// Low-latency startup: reduce probe/analyze time for faster first bytes
'-probesize', '32768',
'-analyzeduration', '0',
// Error resilience: discard corrupt packets, generate timestamps, ignore DTS, no buffering
'-fflags', '+genpts+discardcorrupt+igndts+nobuffer',
// Ignore errors in stream and continue
'-err_detect', 'ignore_err',
// Limit max demux delay to prevent buffering issues with bad timestamps
'-max_delay', '5000000',
// Reconnect settings for network drops
'-reconnect', '1',
'-reconnect_streamed', '1',
@@ -40,6 +45,9 @@ router.get('/', (req, res) => {
// Convert AAC from ADTS format (TS) to ASC format (MP4)
// Required when remuxing MPEG-TS with AAC audio to MP4
'-bsf:a', 'aac_adtstoasc',
// Handle timestamp discontinuities at output
'-fps_mode', 'passthrough',
'-max_muxing_queue_size', '1024',
// Fragmented MP4 for streaming (browser-compatible)
'-f', 'mp4',
'-movflags', 'frag_keyframe+empty_moov+default_base_moof',
+5 -2
View File
@@ -25,8 +25,11 @@ router.get('/', (req, res) => {
const args = [
'-hide_banner',
'-loglevel', 'warning',
// Error resilience: discard corrupt packets, generate timestamps, ignore DTS
'-fflags', '+genpts+discardcorrupt+igndts',
// Low-latency startup: reduce probe/analyze time for faster first bytes
'-probesize', '32768',
'-analyzeduration', '0',
// Error resilience: discard corrupt packets, generate timestamps, ignore DTS, no buffering
'-fflags', '+genpts+discardcorrupt+igndts+nobuffer',
// Ignore errors in stream and continue
'-err_detect', 'ignore_err',
// Limit max demux delay to prevent buffering issues with bad timestamps