Skip to main content
LIVE_HUD STREAMRELAY LAB // MEDIAMTX RTMP -> LL-HLS / WHEP / SRT AUDIT 2026-11-19 | GO RSS: 90-450 MB | EGRESS: UNMETERED VDS VS 10 GBPS
MediaMTXRTMP
MediaMTXRTMP Disclosure: Outbound /go/ links marked rel="sponsored" may earn a referral fee at zero checkout surcharge (Disclosures).
Broadcast Fixes // StreamRelay Lab

FFmpeg 1080p+720p+480p ABR Ladder & 2s Keyframe Alignment

When viewers on mobile connections buffer on a 10 Mbps source stream, a 3-rung FFmpeg ABR ladder lets players drop seamlessly to 720p or 480p without stalling.

Measured MediaMTX & FFmpeg Telemetry

To switch smoothly between 1080p, 720p, and 480p in HLS, every rung must emit an IDR keyframe on the exact same frame boundary (-g 120 for 60fps or -g 60 for 30fps, with -sc_threshold 0).

Subsystem / SignalMeasured TargetOperational Impact
Blended Viewer Bitrate~68% of top rung + 0.18 MbpsSaves ~30% egress vs 100% 1080p
CPU Core Requirement4 - 8 Dedicated CoresUse UltaHost VDS 16 or VDS 32
GOP / Keyframe Lock2.0s (-g 120 -sc_threshold 0)Required for glitch-free ABR switching

Step-by-Step Triage & Config Remediation

  1. Split decoded stream once: Use -filter_complex "[0:v]split=3..." so FFmpeg decodes the RTMP source only once.
  2. Disable scene-cut keyframes: Pass -sc_threshold 0 alongside -g 120 so IDR frames never drift across rungs.
  3. Trigger via runOnReady: Let MediaMTX launch ffmpeg-abr.sh automatically when OBS connects and stop cleanly on disconnect.
ffmpeg -hide_banner -loglevel warning -i "rtmp://127.0.0.1:1935/live/ingest" \
  -filter_complex "[0:v]split=3[v1080][v720][v480];[v720]scale=-2:720[s720];[v480]scale=-2:480[s480]" \
  -map "[v1080]" -map 0:a -c:v libx264 -preset veryfast -tune zerolatency -g 120 -sc_threshold 0 -b:v 6000k -c:a aac -b:a 160k -f flv "rtmp://127.0.0.1:1935/live/1080p" \
  -map "[s720]"  -map 0:a -c:v libx264 -preset veryfast -tune zerolatency -g 120 -sc_threshold 0 -b:v 3000k -c:a aac -b:a 128k -f flv "rtmp://127.0.0.1:1935/live/720p" \
  -map "[s480]"  -map 0:a -c:v libx264 -preset veryfast -tune zerolatency -g 120 -sc_threshold 0 -b:v 1200k -c:a aac -b:a 96k -f flv "rtmp://127.0.0.1:1935/live/480p"

Diagnostic FAQ

Why include -sc_threshold 0 in ABR scripts?

Without -sc_threshold 0, x264 inserts extra scene-cut IDR frames at different timestamps across 720p and 480p, breaking HLS segment alignment.

Should I use -preset ultrafast if CPU hits 100%?

Use ultrafast only as an emergency bridge; veryfast delivers much cleaner detail per Mbps at 4-8 dedicated cores.

Related Broadcast Fixes Guides

MediaMTXRTMP: Size egress Mbps & ABR cores before go-live Launch UltaHost VDS