What the setting actually controls
The keyframe interval is the distance between two complete pictures in your video. Most frames an H.264 encoder sends are only changes from the frames around them. A keyframe, or I-frame, is different: RFC 8216, the HLS specification, describes I-frames as frames whose encoding does not depend on any other frame. An IDR frame is the strict kind of keyframe that also tells the decoder to forget everything before it, so decoding can start cleanly from that point.
The run of frames from one keyframe to the next is the group of pictures, or GOP. That is why FFmpeg calls its setting -g, the GOP size, and why some encoders ask for a number of frames while others ask for seconds. Both describe the same gap.
Why HLS playback depends on a steady gap
Your channel takes RTMP from your encoder and plays as HLS in the browser, so the HLS rules decide what a good interval is. Three of them matter here.
- Segments open on an IDR frame. Apple's authoring specification says video segments must start with one. The packager can only cut where your encoder put an IDR, so every segment's length is a whole number of keyframe gaps.
- Segments have a ceiling. RFC 8216 makes
EXT-X-TARGETDURATIONthe maximum segment length. Apple's specification suggests 6-second target durations and segments of nominally 6 seconds. A 2-second gap divides into that evenly; a wandering gap does not. - Players start a few segments back. For a live playlist, RFC 8216 says a client should not pick a segment that starts less than three target durations from the end. Longer segments push every viewer further behind the live moment.
Put simply: if keyframes arrive every 2 seconds, segments come out even and short, and the player can join from any of them. If the encoder is left on auto, the gap is whatever that encoder picks, and segment lengths follow it.
Shorter is not better without limit. A keyframe holds a full picture, so packing them much closer than 2 seconds spends more of your bitrate on them and leaves less for the moving parts of the image.
Settings to copy, by frame rate
When an encoder asks for frames rather than seconds, multiply your frame rate by 2. Keep the frame rate fixed too: a frame-count interval only means 2 seconds while the frame rate stays where you set it.
| Frame rate | Keyframe interval in seconds | Same interval in frames |
|---|---|---|
| 25 fps | 2 | 50 |
| 30 fps | 2 | 60 |
| 50 fps | 2 | 100 |
| 60 fps | 2 | 120 |
On your live video channel, a paid plan takes 1080p, and each channel's ingest is capped at 5 Mbps. The free plan is for wiring up your encoder and player, which makes it a sensible place to get this setting right before an audience arrives. On paid plans you also get a branded TV app for Samsung and LG sets; the app publishing runbooks cover putting it in the stores.
Where each encoder keeps it
| Encoder | Where to find it | Unit | Enter |
|---|---|---|---|
| OBS Studio | Settings, Output, Output Mode set to Advanced, Streaming tab: Keyframe Interval (0=auto) | Seconds | 2 |
| vMix | Streaming Quality window: Keyframe Frequency | Seconds | 2 (the vMix default) |
| Wirecast | Window menu, Encoder Presets, your H.264 or x264 profile: the key frame value | Frames | Twice the frame rate |
| FFmpeg | The -g option, with -keyint_min set to the same number | Frames | Twice the frame rate |
In OBS, do not leave the field on 0. Zero means auto, which hands the decision to the encoder; the Advanced Recording Settings Guide on the OBS knowledge base also uses 2 for every encoder it covers: x264, NVENC, AMD and QuickSync. Once the interval is set, the rest of the encoder setup is the RTMP address and stream key your control panel shows for the channel.
In Wirecast, remember the value counts frames. If you change a preset from 30 fps to 25 fps and leave the key frame value at 60, the gap grows to 2.4 seconds.
Pinning the gap in FFmpeg
FFmpeg needs four output options to hold a fixed gap. For 30 fps output they read:
-r 30 -g 60 -keyint_min 60 -sc_threshold 0
-r 30fixes the output frame rate, so 60 frames always means 2 seconds.-g 60sets the GOP size, the longest gap allowed. Leave it out and the encoder's own default decides, so always set it.-keyint_min 60sets the minimum GOP size (libx264 caps it at about half of -g). Combined with -g 60 and -sc_threshold 0, the encoder places a keyframe every 60 frames and adds none in between.-sc_threshold 0sets the scene-change detection threshold, so a hard cut in your picture does not add a keyframe off the beat.
If your source's frame rate drifts, FFmpeg also accepts a time-based rule. Its documentation gives expr:gte(t,n_forced*5) as the way to force a keyframe every 5 seconds. For the HLS advice, use 2 and quote it on a shell command line: -force_key_frames "expr:gte(t,n_forced*2)"
Checks before you go live
Do not trust the settings screen alone. Measure what actually leaves the encoder or arrives at the player. ffprobe, which ships with FFmpeg, lists every video packet and flags the keyframes with a K. Point it at a test recording made with the same settings, or at your channel's HLS link while you are live:
ffprobe -v error -select_streams v:0 -show_entries packet=pts_time,flags -of csv -read_intervals "%+20" INPUT
- Replace INPUT with the file path or the HLS link, in quotes if it holds spaces or symbols. The
%+20interval reads only the first 20 seconds, so it stops on its own even on a live link. - Look at the lines whose flags column starts with K. Those are keyframes; the number before the flags is the time in seconds.
- Subtract each keyframe time from the next. At a 2-second interval every difference is 2.0, give or take a frame. Longer or uneven gaps mean the encoder is still on auto or adding scene-change keyframes.
- Fetch the HLS playlist as text, for example with curl. The
#EXTINFvalues are segment lengths in seconds; with a steady 2-second gap each one comes out as a multiple of 2. If the link lists other playlists instead of segments, open the one it names.
When it goes wrong
- The player takes a long time to show a picture. Check the interval first. A long or automatic gap means long segments, and the player starts several segments back from the live end.
- The delay behind real time grew after a settings change. A frame-count interval that no longer matches the frame rate is one likely cause. Recalculate it from the table above.
- ffprobe shows keyframes at irregular times. Scene-change detection is the likely source of the extras. Turn it off in the encoder, or in FFmpeg set
-keyint_minequal to-gwith-sc_threshold 0. - Everything checks out and playback still stutters. Look at bitrate and upload next: a PRO or Platinum channel ingests at most 5 Mbps, and your connection has to carry whatever the encoder sends. If you are stuck, open a ticket or start a chat: live chat answers day and night; its AI assistant reads your account details, and a person steps in whenever you ask for one.