If your stream buffers, takes too long to switch quality, or throws a “keyframe interval too high” warning, the culprit is usually one small encoder setting: the keyframe interval. Get it right and playback is smooth, seeking is instant, and adaptive bitrate switching happens without a visible glitch. Get it wrong and viewers see stutters, delays, and dropped frames.
The keyframe interval controls how often your encoder inserts a full, self-contained frame into the video. It shapes compression efficiency, bandwidth usage, latency, and how well your stream plays across devices. For anyone building on top of live streaming APIs or configuring an encoder like OBS, understanding this setting is the difference between a professional-grade stream and a frustrating one.
This guide breaks down what a keyframe interval is, how it works under the hood, the best settings for each platform, and how it interacts with HLS and adaptive bitrate streaming.
What Is a Keyframe Interval?
A keyframe interval is the amount of time (or number of frames) between two consecutive keyframes in a video stream. A keyframe — technically called an I-frame (intra-frame) — is a complete, standalone image that holds all the visual data needed to render that moment without referencing any other frame.
The frames between keyframes are P-frames and B-frames. Instead of storing a full picture, they store only the changes from surrounding frames. This is what makes modern video encoding so efficient: most frames only describe motion and difference, not the entire scene.
A group of frames that starts with one keyframe and runs until the next is called a Group of Pictures (GOP). In practice, “keyframe interval,” “GOP size,” and “I-frame interval” all describe the same thing: how frequently a full reference frame appears.
Here are the three frame types you’ll encounter:
| Frame type | What it stores | Size | Role |
|---|---|---|---|
| I-frame (keyframe) | The complete image | Largest | Reference point; can be decoded alone |
| P-frame | Changes from the previous frame | Medium | Predicts forward from an earlier frame |
| B-frame | Changes from previous and next frames | Smallest | Bidirectional prediction, highest compression |
A keyframe interval of 2 seconds at 30 fps means a new keyframe is inserted every 60 frames. Everything in between is reconstructed from that keyframe plus the motion data in the P- and B-frames.
Keyframe Interval vs GOP Size vs I-Frame Interval
These three terms cause a lot of confusion, so let’s settle it. They refer to the same underlying concept measured in slightly different units.
- Keyframe interval is usually expressed in seconds (e.g., “2 seconds”). This is what streaming platforms and OBS ask for.
- GOP size is usually expressed in frames (e.g., “60 frames”). Command-line tools like FFmpeg use this.
- I-frame interval is another name for the same setting, common in hardware encoders and mobile SDKs.
The conversion is simple:
GOP size (frames) = keyframe interval (seconds) × frame rate (fps)
So a 2-second keyframe interval at 60 fps equals a GOP size of 120 frames. At 30 fps, it’s 60 frames. When a platform says “set keyframe interval to 2” and your encoder asks for GOP in frames, multiply by your frame rate.
One more distinction: an IDR frame (Instantaneous Decoder Refresh) is a special kind of keyframe that also clears the decoder’s reference buffer, guaranteeing that nothing after it depends on anything before it. For streaming, keyframes at GOP boundaries are almost always IDR frames — this is what lets a player join a stream or switch quality cleanly.
How Does a Keyframe Interval Work?
To understand why this setting matters, it helps to see what happens when a player receives your stream.
-
The decoder needs a keyframe to start. A player can’t render P- or B-frames on their own — they only make sense relative to a keyframe. When a viewer joins your stream or seeks to a new spot, playback can’t begin until the next keyframe arrives.
-
P- and B-frames fill the gap. Once the keyframe is decoded, the encoder reconstructs each following frame by applying the stored motion and difference data. This is where compression savings come from.
-
The cycle repeats at every interval. When the keyframe interval elapses, the encoder inserts a fresh keyframe and starts a new GOP. This periodic “reset” is what allows random access into the stream.
The trade-off sits right here. A shorter keyframe interval inserts full frames more often, which improves seek accuracy and quality on fast-moving content — but keyframes are large, so file size and video bitrate requirements go up. A longer keyframe interval compresses better and saves bandwidth, but makes seeking less precise and can slow down how quickly viewers can join or switch quality.
Because keyframes are the heaviest frames in the stream, the keyframe interval is one of the biggest levers you have over the balance between quality and bandwidth for streaming.
Why the Keyframe Interval Matters for Streaming
The keyframe interval touches almost every part of the viewing experience. Here’s what it affects.
Playback startup and join time
Viewers can only begin watching at a keyframe. If your interval is 10 seconds, a new viewer might wait up to 10 seconds before the picture appears. A 2-second interval keeps join times short and responsive.
Adaptive bitrate switching
In adaptive bitrate streaming, the player jumps between quality renditions based on network conditions. Those switches can only happen at keyframe boundaries that line up across every rendition. A consistent, aligned keyframe interval is what makes ABR switches invisible instead of jarring.
Latency
For low latency streaming, shorter GOPs generally help players start and recover faster. Overly long intervals add delay because the player must wait longer for the reference frames it needs.
Seeking and scrubbing
For recorded or live-to-VOD content, keyframes are the only points you can accurately jump to. More keyframes mean smoother scrubbing on the timeline.
Bandwidth and quality
Every keyframe is a full image, so more keyframes mean more data. On a fixed bitrate budget, packing in too many keyframes steals bits from the rest of the picture and can lower overall quality — especially noticeable on high-motion scenes.
Recovery from packet loss
If a keyframe is lost or corrupted in transit, the whole GOP can break until the next one arrives. Shorter intervals recover faster from network hiccups, which matters for protocols like RTMP over unreliable connections.
What Is the Best Keyframe Interval for Streaming?
For almost all live streaming, a 2-second keyframe interval is the safe, industry-standard choice. It balances fast join times, clean ABR switching, and reasonable compression, and it’s what the major platforms explicitly ask for.
Here’s what the biggest destinations recommend:
| Platform | Recommended keyframe interval | Notes |
|---|---|---|
| YouTube Live | 2 seconds (4 seconds max) | Required for stable ingest |
| Twitch | 2 seconds | “Keyframe interval too high” warning above this |
| Facebook Live | 2 seconds | Streams may be rejected otherwise |
| HLS delivery | 2 seconds (must divide segment length) | Aligns with segment boundaries |
| Low-latency streaming | 1–2 seconds | Shorter helps reduce delay |
| VOD / high quality | 2–5 seconds | Longer OK when seeking is less critical |
A few practical guidelines:
- Live streaming: Stick with 2 seconds. It’s compatible with virtually every platform and CDN. YouTube’s recommendation of a 2-second GOP is documented in its live encoder settings.
- Fast-motion content (gaming, sports): 1–2 seconds keeps quality sharp during rapid scene changes.
- Static or talking-head content: You can push toward 2–4 seconds to save bandwidth without noticeable quality loss.
- Recording only (not streaming): Longer intervals of 5–10 seconds are fine and save file size, since ABR and join-time constraints don’t apply.
Avoid “auto” and “0” settings in your encoder (more on that below). And never set the interval based on frame count if the platform asks for seconds — remember to convert.
Keyframe Interval and HLS / Adaptive Bitrate Alignment
This is where keyframe interval stops being a “nice to know” and becomes a hard requirement. If you’re delivering with HLS or MPEG-DASH, your keyframe interval and your segment length are tightly linked.
The rule: every HLS segment must begin with a keyframe, and segment duration must be an integer multiple of the GOP duration.
Say you use 6-second HLS segments. Your GOP duration must divide evenly into 6 seconds — so 1s, 1.5s, 2s, 3s, or 6s all work, but 4s or 5s don’t. If they don’t divide cleanly, the encoder either inserts extra keyframes (wasting bandwidth) or produces misaligned segments that break clean adaptive switching. Apple’s HLS authoring specification formalizes these alignment rules.
For adaptive bitrate to work, keyframes must be aligned across every rendition — the 1080p, 720p, and 480p versions all need their keyframes at the same timestamps. Only then can the player swap from one quality to another mid-stream without a visible glitch. This is also why formats like CMAF rely on disciplined GOP structures.
The practical takeaway: a 2-second keyframe interval divides neatly into the most common segment lengths (2s, 4s, 6s), which is a big reason it became the default. If you’re managing your own transcoding pipeline, this alignment is something you have to enforce yourself. If you use a managed encoding layer, it should handle it automatically.
How to Set the Keyframe Interval in OBS and Other Encoders
Most keyframe interval questions come from OBS users, so let’s cover it directly, then look at command-line tools.
Setting the keyframe interval in OBS
- Open Settings → Output and switch Output Mode to Advanced.
- Go to the Streaming tab.
- Find the Keyframe Interval (seconds, 0 = auto) field.
- Enter 2.
That’s it. The same setting lives in Streamlabs under Output settings, labeled identically. Whatever you set here applies to your live stream; recording has a separate keyframe interval field if you want a different value for local files.
Setting GOP size in FFmpeg
If you’re scripting your own encoder, FFmpeg uses the -g flag for GOP size in frames. For a 2-second interval at 30 fps:
ffmpeg -i input.mp4 \
-c:v libx264 \
-g 60 \
-keyint_min 60 \
-sc_threshold 0 \
-c:a aac \
output.m3u8
Two details matter here:
-keyint_min 60sets the minimum GOP size so keyframes land at fixed, predictable intervals.-sc_threshold 0disables scene-cut detection, which otherwise inserts extra keyframes at scene changes and breaks your fixed GOP alignment — critical for HLS.
This combination gives you a rock-solid, evenly spaced keyframe interval, which is exactly what adaptive streaming needs.
Hardware and mobile encoders
Hardware encoders (and mobile SDKs using NVENC, QuickSync, or platform APIs) usually expose an “I-frame interval” or “GOP” parameter. The same math applies: interval in seconds × frame rate = GOP in frames. Whatever you’re using to feed a live streaming encoder, the goal is a fixed, aligned interval.
Common Keyframe Interval Problems (and Fixes)
A handful of issues come up again and again. Here’s how to resolve them.
“Keyframe interval too high” warning
Twitch, YouTube, and multistreaming tools flag this when your GOP exceeds their limit (usually 2–4 seconds). The fix is simple: set your keyframe interval to exactly 2 seconds in your encoder. This is the single most common streaming misconfiguration.
Keyframe interval “0 or 2” — which to choose?
Many encoders default to 0, which means “auto” — the encoder decides where to place keyframes, often inserting them at scene changes rather than fixed intervals. For streaming, this is a problem: unpredictable keyframe placement breaks HLS segment alignment and confuses adaptive bitrate switching. Always choose 2 over 0 for live streaming. Set an explicit interval so keyframes are evenly spaced.
Buffering after switching quality
If your stream stutters whenever the player changes resolution, your keyframes probably aren’t aligned across renditions. Every quality level needs keyframes at the same timestamps. A fixed 2-second interval with scene-cut detection disabled usually fixes it, and this is a frequent cause of buffering during playback.
High latency
Very long intervals (8–10 seconds) increase the delay before a player can start or recover. If you’re chasing lower latency, drop to 1–2 seconds and pair it with a low-latency delivery configuration.
Bloated file size on recordings
If your recordings are unexpectedly large, an overly short keyframe interval may be the reason — each keyframe is heavy. For recording-only workflows, a longer interval (5+ seconds) shrinks files without hurting the streaming experience.
Understanding the keyframe interval is one thing; enforcing it correctly across every rendition, aligning it to segment boundaries, and keeping it consistent under real-world network conditions is another — especially at scale. That’s the part most teams don’t want to build and maintain themselves.
How LiveAPI Handles Keyframe Intervals for You
When you build video features with LiveAPI, you don’t have to hand-tune GOP structures or worry about whether your segments align. LiveAPI’s video encoding API manages keyframe placement, segment alignment, and rendition consistency automatically as part of its transcoding pipeline.
Here’s what that means in practice:
- Ingest from any encoder. Push your stream over RTMP or SRT from OBS, a hardware encoder, or a mobile SDK. Whatever keyframe interval your source sends, LiveAPI’s instant encoding produces properly structured output.
- Aligned adaptive bitrate output. LiveAPI generates multiple quality renditions with keyframes aligned across every level, so ABR switching stays smooth and viewers never see a glitch when their bandwidth changes.
- Clean HLS delivery. Output is delivered as HLS with correctly aligned segment boundaries across multiple CDNs (Akamai, Cloudflare, Fastly), so playback starts fast and stays smooth worldwide.
- Low-latency ready. GOP structure is optimized for delivery, helping you keep latency down without manual encoder gymnastics.
Instead of debugging “keyframe interval too high” warnings or misaligned segments, you send a stream and get back reliable, standards-compliant output. That’s the whole point of building on a video streaming API instead of assembling the pipeline yourself.
Keyframe Interval FAQ
What is a keyframe interval in simple terms?
A keyframe interval is how often a video inserts a full, complete image (a keyframe) among the compressed frames that only store changes. It’s usually measured in seconds — a 2-second interval means one full frame every 2 seconds, with the rest reconstructed from motion data.
What is the best keyframe interval for streaming?
Two seconds is the best choice for almost all live streaming. It’s the value YouTube, Twitch, and Facebook recommend, and it aligns cleanly with common HLS segment lengths, giving you fast join times and smooth adaptive bitrate switching.
Is keyframe interval the same as GOP size?
Yes — they describe the same setting. Keyframe interval is typically measured in seconds, while GOP size is measured in frames. Multiply the interval by your frame rate to convert (2 seconds × 30 fps = 60-frame GOP).
Should I set keyframe interval to 0 or 2?
Set it to 2 for streaming. A value of 0 means “auto,” letting the encoder place keyframes unpredictably, which breaks HLS segment alignment and adaptive bitrate switching. An explicit 2-second interval keeps keyframes evenly spaced.
Why do I get a “keyframe interval too high” warning?
Your encoder’s keyframe interval exceeds the platform’s limit, usually 2 seconds. Open your encoder settings and set the keyframe interval to exactly 2 seconds to clear the warning and ensure stable ingest.
Does a shorter keyframe interval improve quality?
It can improve quality on high-motion content and speed up seeking, but each keyframe is large, so shorter intervals consume more bandwidth. On a fixed bitrate, too many keyframes can actually reduce overall quality by leaving fewer bits for the rest of the picture.
How does keyframe interval affect latency?
Shorter intervals generally lower latency because players can start and recover faster when keyframes arrive more often. Very long intervals (8–10 seconds) add delay since the player waits longer for the reference frames it needs.
What keyframe interval should I use for recording versus streaming?
For streaming, use 2 seconds. For recording only, you can use a longer interval (5–10 seconds) to save file size, since adaptive bitrate switching and join-time constraints don’t apply to local files.
Final Thoughts
The keyframe interval is a small setting with outsized impact. It governs how quickly viewers can join, how smoothly quality adapts, how much bandwidth you burn, and whether your HLS segments line up at all. For nearly every live streaming scenario, 2 seconds is the answer — it satisfies every major platform and divides neatly into standard segment lengths.
If you’d rather not manage GOP alignment, rendition consistency, and segment boundaries by hand, let infrastructure handle it. Get started with LiveAPI and ship reliable, adaptive video streaming — with the encoding details taken care of for you.


