Video - Video & Streaming
CDN for Live Courses: Setup & Strategy
Live course streaming in 2026 is a one-to-many video problem with a tight latency budget. Classic HLS with 6-second ...
HLS encoding that plays smoothly comes down to three linked numbers: a segment target duration, a fixed keyframe interval that divides it exactly, and a rendition ladder in which every rung places keyframes at the same timestamps. This playbook walks through each setting with the exact ffmpeg flags and values, then shows how to validate the output. Expect 60 to 90 minutes from a mezzanine file to a validated, multi-rendition fMP4 package.
As of 2026, Apple's HLS authoring specification recommends a 6-second target segment duration with a keyframe every 2 seconds, which is 48 frames at 24 fps or 60 frames at 30 fps. Every rendition in the ladder must share those keyframe positions, or players stall and show visual glitches when they switch bitrates.
Use 6 seconds for video on demand and 2 to 4 seconds for standard-latency live. A 6-second HLS segment length keeps request counts and per-segment overhead low. Shorter segments start playback faster and adapt sooner, but each one must begin on a keyframe, so you pay for extra IDR frames in bitrate and in object count.
The trade-off is quantifiable. A 2-hour film cut into 6-second segments produces 1,200 segments per rendition. With five video renditions and one audio rendition that is 7,200 objects. At 2-second segments the same title becomes 21,600 objects, three times the request rate against the edge and three times the playlist length the player parses.
Live latency moves in the opposite direction. Most players hold about three segments before starting, so 6-second segments put a viewer roughly 18 seconds or more behind the encoder, while 2-second segments bring that down to about 6 to 8 seconds. If you need sub-5-second glass-to-glass latency, plain HLS segments are the wrong tool, and Low-Latency HLS (LL-HLS) partial segments are the next step.
Pick the segment duration first, then set the Group of Pictures (GOP) so that a whole number of GOPs fits inside each segment. The rule is simple: GOP frames equal frame rate times GOP seconds, and the segment duration must be an exact multiple of the GOP duration.
The matrix below is the worked arithmetic for common frame rates with a 2-second GOP, which divides 4-second and 6-second segments evenly.
| Frame rate | GOP (2 s) in frames | GOPs per 4 s segment | GOPs per 6 s segment |
|---|---|---|---|
| 24 fps | 48 | 2 | 3 |
| 25 fps | 50 | 2 | 3 |
| 30 fps | 60 | 2 | 3 |
| 29.97 fps | 60 (actual GOP 2.002 s) | 2 (4.004 s) | 3 (6.006 s) |
| 50 fps | 100 | 2 | 3 |
| 60 fps | 120 | 2 | 3 |
Fractional rates such as 29.97 fps are the only case where segment durations drift above the nominal value, so fix the GOP in frames rather than in seconds for those sources.
Why it matters: the ffmpeg HLS muxer can only cut a segment at a keyframe. If the GOP does not divide the target, the muxer waits for the next keyframe, and a 6-second target turns into a sequence of 6, 8 and 10-second segments that inflate EXT-X-TARGETDURATION and the player's buffer requirement.
Keyframe alignment means the IDR frame at, say, 12.000 seconds exists in the 1080p, 720p and 360p outputs alike. The default x264 behavior breaks this, because scene-cut detection inserts extra keyframes wherever the picture changes, and those decisions differ by resolution. Set these flags on every video output:
| ffmpeg flag | Value (30 fps source) | Why |
|---|---|---|
| -g | 60 | Maximum GOP length of 2 seconds |
| -keyint_min | 60 | Prevents shorter GOPs |
| -sc_threshold | 0 | Disables scene-cut keyframes that differ per rung |
| -force_key_frames | expr:gte(t,n_forced*2) | Pins IDR frames to exact 2-second timestamps |
| -bf | 2 or 3 | B-frames stay legal inside closed GOPs |
The force_key_frames expression is the safety net: even if the frame rate wobbles, IDR frames land on time-based boundaries that match across renditions.
If you encode renditions in separate ffmpeg processes or on separate machines, these flags are what keep them aligned. Encoding all rungs in one process with the split filter is simpler and guarantees an identical input timeline.
A rendition ladder is the set of resolution and bitrate pairs listed in the multivariant playlist. Space adjacent rungs roughly 1.5 to 2 times apart in bitrate so the player has a meaningful step down under congestion without jumping straight to an unwatchable rung. The H.264 values below are starting points for typical live-action content at 30 fps, not tuned numbers.
| Rung | Resolution | Target video bitrate | maxrate / bufsize |
|---|---|---|---|
| 1 | 1920x1080 | 6,000 kbps | 6,600k / 12,000k |
| 2 | 1280x720 | 3,000 kbps | 3,300k / 6,000k |
| 3 | 960x540 | 1,600 kbps | 1,760k / 3,200k |
| 4 | 640x360 | 800 kbps | 880k / 1,600k |
| 5 | 416x234 | 300 kbps | 330k / 600k |
Capping maxrate at about 110% of target keeps the measured peak close to the BANDWIDTH attribute, which is what players use to choose a rung.
Use capped VBR (target bitrate with -b:v, plus -maxrate and -bufsize) rather than uncapped CRF. Uncapped CRF lets a high-motion segment spike to three times the advertised bitrate, and a player that trusted BANDWIDTH will rebuffer. Encode audio once as 128 kbps stereo AAC at 48 kHz and reference it from every variant instead of duplicating it per rung.
The ffmpeg hls muxer writes media playlists, segments and the multivariant playlist in one pass. These are the packaging flags that matter for a VOD title in fMP4 segments:
For live, swap -hls_playlist_type vod for a sliding window: -hls_list_size 6 with -hls_flags delete_segments plus independent_segments, and drop -hls_time to 2 with a 1-second or 2-second GOP.
Check three things: keyframe positions, segment durations and declared versus measured bitrate. Each has an expected value you can compare against in minutes.
Write every new ladder to a versioned path, such as a directory named after the encode profile and date, and never overwrite segments in place. Rollback is then a one-line change to which multivariant playlist your player or manifest service points at. Overwriting segments under the same URLs is the mistake to avoid: edges will serve a mix of old and new segments until caches expire, and mismatched init segments break playback outright.
Start with 6 seconds and move to 4 only if startup time or switch responsiveness is a measured problem. Each halving of segment duration doubles IDR frames per minute; at low bitrates that typically costs a few percent of compression efficiency, which shows up as visible softness on the bottom rungs.
Then tune the ladder to the content. Animation and slide-based lectures look clean at roughly half the bitrates in the table, while sports needs more headroom at 720p and above. Per-title encoding, where you run test encodes and choose rungs from a quality metric such as VMAF, is the logical next step once the pipeline is stable.
Delivery cost follows these choices too, because 2-second segments triple the object count per title. BlazingCDN's HLS Streaming CDN for pre-encoded HLS and LL-HLS serves the packaged segments with unlimited requests and no request fees, but it does not transcode, so the encoding steps above stay in your pipeline.
Six seconds is the standard HLS segment length for video on demand. It keeps object counts and playlist size manageable while giving players enough segments to adapt. Shorter segments, such as 2 or 4 seconds, improve startup and switching speed but add IDR frames, which raises bitrate at equal quality and triples requests at 2 seconds.
Set the same fixed GOP on every rendition and disable scene-cut detection. In ffmpeg that means matching -g and -keyint_min values, -sc_threshold 0, and a time-based force_key_frames expression. Encoding all renditions in a single ffmpeg process with the split filter also guarantees every rung reads an identical input timeline.
The ffmpeg HLS muxer can only cut segments at keyframes, so segments run long when the GOP does not divide hls_time. A 6-second target with a 5-second GOP produces 10-second segments. Variable frame rate sources cause the same drift. Fix the GOP in frames and convert the source to constant frame rate before encoding.
Use fMP4 for new HLS encoding pipelines. Fragmented MP4 segments are required for HEVC in HLS, work with CMAF so the same segments can serve DASH, and avoid MPEG-TS overhead. Keep MPEG-TS only for legacy devices that predate fMP4 support, and confirm that requirement against your actual player analytics first.
This week, pull one title from your existing catalog and run the ffprobe keyframe check against its top and bottom renditions. If the timestamp lists differ, you have found the cause of switch glitches your QoE dashboards attribute to the network. Then compute the object count per title at your current segment length and at 2 seconds, and compare it with your edge request bill and cache hit ratio, since that number decides whether shorter segments are affordable.
If your packaged HLS library is ready for a new delivery layer, the BlazingCDN OTT and VOD streaming CDN page covers how it serves pre-encoded segments, and a 14-day testing period on real production traffic is available for that comparison.
Heavy traffic.
Light bill.
The CDN for video and large traffic
Video - Video & Streaming
Live course streaming in 2026 is a one-to-many video problem with a tight latency budget. Classic HLS with 6-second ...
Video - Video & Streaming
To reduce streaming latency, shrink the buffer the player is forced to hold, then make the CDN deliver partial segments ...
Video - Video & Streaming
A live HLS channel with 6-second segments and 100,000 concurrent viewers puts roughly 33,000 requests per second on the ...
Video - Video & Streaming
As of 2026, the difference between a sports stream that feels live and one that feels delayed is mostly settled before ...