Skip to content
Encoding & Compression

What Is a Keyframe (GOP)? Why It Matters for Streaming

What is a keyframe in video? Learn how I, P and B frames work, what a GOP is, and the keyframe interval to use for streaming, editing and live video.

What Is a Keyframe (GOP)? Why It Matters for Streaming
On this page 14 sections

Scrub through a video on a slow connection and it may jump to the nearest “clean” point instead of the exact second you clicked. Start a live stream and your platform may warn about your “keyframe interval”. Both come down to one idea. So what is a keyframe, and why does it matter so much for streaming? This guide explains it simply, then gives the settings to use.

The short answer

A keyframe is a complete picture stored in the video. The frames between keyframes are stored as changes from the frames around them. A player can start decoding at a keyframe, but not in the middle of a run of change-only frames. That single fact drives seeking, quality switching, streaming segment sizes and even how your file looks after a scene cut.

Three kinds of frames

Most modern codecs, including H.264, HEVC and AV1, use three frame types.

I-frames (intra frames). A full picture, compressed on its own like a photo. These are the keyframes. They are the largest frames in the file.

P-frames (predicted frames). Store only what changed since an earlier frame. If a presenter nods, the P-frame describes the head movement and reuses everything else. Much smaller than I-frames.

B-frames (bi-directional frames). Look both backwards and forwards, borrowing from earlier and later frames. The smallest and most efficient, at the cost of some extra complexity in decoding.

A typical sequence might look like I B B P B B P B B P ... and then another I.

What a GOP is

A group of pictures (GOP) is the run of frames from one keyframe up to, but not including, the next. The GOP length or keyframe interval is how far apart keyframes are, measured in frames or seconds.

At 30 frames per second, a 60-frame GOP means a keyframe every two seconds. At 25 fps, 50 frames gives the same two seconds.

IDR frames

There is one more distinction worth knowing. An IDR frame (instantaneous decoder refresh) is a keyframe that also clears the decoder’s memory. No frame after it may refer to anything before it. A plain I-frame does not always guarantee that.

For streaming, this matters. Every segment should begin with an IDR frame so a player can start there without needing earlier data.

Open and closed GOPs

In a closed GOP, frames only refer to frames inside the same group. In an open GOP, some B-frames at the start of a group borrow from the end of the previous group. Open GOPs are slightly more efficient, but they complicate cutting video into independent pieces. Streaming packagers and many platforms expect closed GOPs, or at least an IDR frame at each segment boundary.

Why keyframes matter for streaming

Segments start at keyframes

HLS and DASH cut video into segments, and each segment must start with a keyframe, otherwise the player cannot decode it on its own. If your keyframes land every 2 seconds and your segments are 6 seconds, each segment holds exactly three GOPs. If your keyframes are irregular, segments come out uneven, which can break playlist rules and upset players. We cover the playlist side in HLS streaming explained.

Switching quality needs aligned keyframes

In adaptive bitrate streaming, the player swaps between renditions at segment boundaries. That only works cleanly if every rendition has keyframes at exactly the same moments. When they drift apart, viewers see a glitch or a brief freeze at the switch.

Live streams join faster

When a viewer opens a live stream, the player has to wait for the next keyframe before showing a picture. With a 10-second interval, some viewers stare at a black screen for up to 10 seconds. With 2 seconds, the wait is short.

Seeking is smoother

Jumping to a point in a video means decoding from the nearest earlier keyframe. Long GOPs make seeking slower and less precise, especially in editing software and on slow devices.

The trade-off: keyframes cost bits

Keyframes are big. A two-second interval might spend a noticeable share of the bitrate on I-frames, leaving less for everything else. At a fixed bitrate, more keyframes can mean slightly softer pictures. Longer intervals are more efficient, which is why video files meant for download or archiving often use keyframes every 5 to 10 seconds.

So the right interval depends on the job:

Use Keyframe interval
Live streaming to YouTube, Twitch, Facebook 2 seconds
HLS / DASH on-demand streaming 2 seconds, fixed, aligned across renditions
Low-latency live 1 to 2 seconds
Files for download or archive 5 to 10 seconds, scene-cut keyframes allowed
Editing footage Every frame (intra-only codecs like ProRes)

Scene cuts and keyframes

Encoders normally insert an extra keyframe when the picture changes completely, for example at a cut to a new shot. That is efficient, because predicting a totally new picture from the old one would waste bits. For downloads and archives, leave it on.

For streaming, scene-cut keyframes can break the neat 2-second rhythm. The usual fix is to disable them, or to force keyframes at fixed times and allow extra non-IDR I-frames in between. In FFmpeg with x264, the classic settings are:

-g 60 -keyint_min 60 -sc_threshold 0

That forces an IDR every 60 frames and turns off scene-cut detection. For other frame rates, set -g to twice the frame rate for a 2-second interval. The full streaming recipe is in our guide to converting MP4 to HLS with FFmpeg.

OBS Studio. Settings → Output → set Output Mode to Advanced → Keyframe Interval: 2. Leaving it at 0 means “auto”, which some platforms reject. Our OBS settings guide covers the rest of the setup.

HandBrake. Video tab → Advanced options or the extra options field. For x264, keyint=60:min-keyint=60:scenecut=0 gives fixed 2-second keyframes at 30 fps.

Adobe Premiere Pro and Media Encoder. In H.264 export settings, look for “Key Frame Distance” in the advanced section and set it in frames.

DaVinci Resolve. In the Deliver page, under the advanced encoder options, set the keyframe interval or choose “Every” with a frame count.

Hardware encoders. Most have a GOP or keyframe setting in seconds or frames. Set it to 2 seconds for streaming.

Checking the keyframes in a file

FFprobe can list them:

ffprobe -v error -select_streams v:0 -skip_frame nokey \
  -show_entries frame=pts_time -of csv=p=0 input.mp4

This prints the timestamp of every keyframe. For a streaming file you should see an even rhythm, such as 0, 2, 4, 6. Irregular gaps tell you scene-cut keyframes are still on, or that the encoder was set to “auto”.

Common problems and their causes

Platform warns “keyframe interval too long”. Your encoder is on auto or set above 4 seconds. Set it to 2.

Viewers see a black screen for a few seconds when joining a live stream. Long keyframe intervals. Shorten them.

A brief glitch when quality changes. Keyframes are not aligned across renditions. Re-encode with fixed intervals and no scene-cut keyframes.

Seeking feels sluggish in an editor. The footage uses long GOPs. Create proxy files in an intra-frame codec for editing.

Files are bigger than expected at the same quality. The keyframe interval may be very short. For downloads, lengthen it.

How keyframes affect file size

Because keyframes are large, the interval shows up in the numbers. Encode the same one-minute clip at the same quality with a 1-second, 2-second and 10-second interval, and the 1-second version will usually be the largest by a clear margin. Use the bitrate calculator to see how a few hundred kilobits per second of extra keyframe cost turns into megabytes over a long video.

Keyframes in animation and editing

The word “keyframe” also appears in animation and motion graphics, where it means something different: a point in time where you set a value, such as position or opacity, and the software fills in the frames between. That is a creative tool. The keyframes in this article are a compression concept. Both share the idea of “important frames with the rest filled in”, which is why the same word stuck.

In editing software you may also see “GOP-based” and “intra-frame” footage. GOP-based footage, typical of phones and consumer cameras, uses long runs of P and B frames, which keeps files small but makes scrubbing slow. Intra-frame footage, such as ProRes or DNxHD, makes every frame a keyframe, which is why it edits so smoothly and takes up so much space. Many editors convert phone footage to an intra-frame codec before a big edit for exactly this reason.

A quick rule to remember

For anything that streams, think “two seconds, every rendition, same moment”. For anything people download and keep, let the encoder choose. That covers nearly every situation you will meet, and it is easy to check with the ffprobe command above.

One question we hear often

“If keyframes cost bits, why not use one every ten seconds for live streams too?” Because every viewer who joins, and every quality switch, has to wait for the next one. Two seconds is the balance point most platforms have settled on after years of testing. Unless you have a specific reason, stick with it, and let your encoding settings handle the rest.

Summary

A keyframe is a complete picture that decoding can start from; the frames between keyframes store only changes. A GOP is the run from one keyframe to the next. For streaming, use a fixed 2-second keyframe interval, IDR frames at segment boundaries and aligned keyframes across every rendition, with scene-cut keyframes disabled. For downloads and archives, longer intervals save space. Get this one setting right and a surprising number of streaming problems never appear.

Frequently asked questions

What keyframe interval should I use for Twitch or YouTube?

Two seconds. Both platforms recommend a 2-second keyframe interval for live streams. In OBS, set Keyframe Interval to 2.

Does a shorter keyframe interval improve quality?

No. Shorter intervals make seeking and switching faster but use more bits, so at the same bitrate quality usually drops slightly.

What is the difference between a keyframe and an IDR frame?

Every IDR frame is a keyframe, but it also resets the decoder so no later frame can refer to anything before it. Streaming segments should start with IDR frames.

Keep reading