Use a single ffmpeg command with multiple -map and -vf scale= outputs to encode all renditions in one pass, sharing the decode step for efficiency
Set -g (GOP size) and -keyint_min to a multiple of the segment duration (e.g., 2 s segments → -g 48 at 24 fps) to ensure segments start on keyframes for seamless ABR switching
Use -c:v libx264 with -crf or -b:v per rendition and -c:a aac with -b:a per audio output; set -movflags +faststart for progressive MP4 or leave it off for segmented HLS output
Pass -hls_time, -hls_list_size, -hls_segment_filename, and -master_pl_name flags to the HLS muxer to control segment duration, playlist length, naming, and the master playlist filename
Validate the output with ffprobe on a mid-stream segment to confirm keyframe placement and that the CODECS string in the master playlist matches the actual codec profile/level
Known gotchas
Not aligning keyframes to segment boundaries causes ABR switches to start mid-GOP, producing visible glitches; -force_key_frames 'expr:gte(t,n_forced*SEG_DURATION)' enforces this without changing quality
The ffmpeg HLS muxer defaults to MPEG-TS segments; switch to fMP4 by setting -hls_segment_type fmp4 and bumping EXT-X-VERSION to 7 if you need CMAF compatibility
Omitting -an on video-only outputs when doing a multi-output command causes each video rendition to redundantly include an audio stream, inflating segment sizes
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp