Three kinds of frames
Video codecs such as H.264, HEVC, VP9 and AV1 save space by not storing every frame as a complete picture. Most frames describe only what changed since another frame. That gives three basic frame types.
- I-frame
- Intra-coded. A complete picture compressed on its own, like a still image. Largest of the three
- P-frame
- Predicted. Stores motion and differences relative to one or more earlier frames. Much smaller
- B-frame
- Bi-directionally predicted. Can refer to frames both before and after it. Usually the smallest
A keyframe is an I-frame that a decoder can start from. In H.264 and HEVC the strict version is called an IDR frame, an instantaneous decoder refresh, which tells the decoder to forget every earlier frame. Not every I-frame is an IDR frame, a distinction that matters for open GOPs below. The broader picture of how inter-frame compression works is in our explainer on video codecs.
What a GOP is
A group of pictures is a keyframe plus all the frames that follow until the next keyframe. A pattern might look like I B B P B B P B B P, repeated. Its length is the keyframe interval.
Intervals are often set in frames: 60 frames is 2 seconds at 30 fps or 1 second at 60 fps. Thinking in seconds avoids confusion when you export the same project at different frame rates. Many encoders also insert extra keyframes at scene cuts, because a new shot shares nothing with the previous one and predicting from it would waste bits. The popular x264 encoder, for example, uses a maximum interval of 250 frames by default and adds keyframes at scene changes.
Open and closed GOPs
In a closed GOP, no frame refers to anything outside its own group. You can start decoding at its keyframe and every frame will come out correctly.
In an open GOP, the first few B-frames after a keyframe, which are shown before it, may refer to the last frames of the previous group. That squeezes out a little more efficiency, but it means those leading B-frames cannot be decoded if playback or a cut starts at that keyframe. Decoders typically skip or conceal them.
- Closed GOPs suit editing, splicing, stream switching and any workflow where files are cut at keyframes.
- Open GOPs suit straight-through playback of a finished file, where the small saving is free.
- Many streaming guides and platforms ask for closed GOPs. Encoders expose the choice as an option, often labelled open-gop or closed-gop.
How keyframe spacing affects seeking
When you drag a player's scrubber to 12:34, the player cannot simply decode the frame at 12:34. It has to find the keyframe at or before that point and decode forward through every frame to the one you asked for. With a 1-second interval that is at most a second of decoding, which feels instant. With a 10-second interval it can be up to 10 seconds of frames to decode before the picture appears.
Players handle this in two ways. Some seek precisely and accept the delay. Others snap to the nearest keyframe for speed, which is why scrubbing through some files feels jumpy, landing a few seconds away from where you aimed.
How it affects cutting without re-encoding
Cutting with stream copy, the lossless method used by ffmpeg with -c copy and by many quick trimming tools, can only start a segment cleanly on a keyframe. If you ask for a cut at 12:34 and the nearest keyframe is at 12:30, the tool either begins at 12:30 or keeps the earlier frames and hides them with an edit list. Long intervals therefore mean imprecise cuts. Some editors offer smart rendering, re-encoding only the partial GOP at each cut and copying the rest. The steps for splitting a file this way, including how to pick cut points, are in how to split a video file.
A hypothetical 40-minute screen recording was captured with a keyframe only every 10 seconds, because the screen rarely changed. Trimming the first 2 minutes 34 seconds with stream copy starts the result at 2:30, so four seconds of the host saying hello remain. Re-exporting the recording once with a 2-second keyframe interval makes later lossless trims accurate to within 2 seconds, and the file grows only modestly because the content is mostly static.
How it affects streaming
Adaptive streaming formats such as HLS and DASH split video into segments, and each segment must begin with a keyframe so a player can start there. Players switch between quality levels at segment boundaries, which only works if every quality level has keyframes at the same moments. That is why live-streaming platforms specify a fixed keyframe interval, commonly around 2 seconds, and often ask encoders to disable extra scene-cut keyframes. Requirements vary and change, so check the current documentation of the platform you stream to.
Keyframes also limit how far damage spreads. If a packet is lost or corrupted, every frame that refers to it inherits the error, so the artifact smears across the picture until the next keyframe resets everything. Shorter intervals recover sooner.
How it affects file size
An I-frame costs many times more bits than a P- or B-frame showing similar content, because it cannot borrow anything from its neighbors. More keyframes per minute means more of the bit budget spent on those expensive frames, which leaves less for the rest at the same file size, or a bigger file at the same quality. The effect is strongest for static content, such as slides or screen recordings, where P- and B-frames are tiny, and weakest for constantly changing footage. How bitrate and quality trade off more generally is explained in video bitrate explained.
Editing formats go to the extreme. Intra-only codecs such as ProRes, DNxHR and all-intra H.264 make every frame a keyframe. Files are large, but every frame can be decoded independently, so scrubbing and cutting in an editor are fast.
Choosing a keyframe interval when exporting
- Final delivery file for viewers
- Leave the encoder's default, which usually adds scene-cut keyframes, or set a maximum of a few seconds
- Live streaming
- Use the fixed interval your platform asks for, commonly about 2 seconds, with closed GOPs
- File you will cut or split later
- 1 to 2 seconds, closed GOPs, so lossless cuts land close to where you want
- Editing intermediate
- An intra-only codec, where every frame is a keyframe
- Long screen recordings
- A long interval saves space, but shorten it if you expect to trim or seek a lot
In ffmpeg, the -g option sets the maximum GOP length in frames, so -g 60 on a 30 fps export gives a keyframe at least every 2 seconds. Disabling scene-cut detection (-sc_threshold 0 with x264) makes the interval fixed. In graphical editors, look for a setting called keyframe interval, keyframe distance or GOP size in the advanced export options.
To see where an existing file's keyframes are, run ffprobe -v error -select_streams v:0 -skip_frame nokey -show_entries frame=pts_time -of csv input.mp4, which lists the time of each keyframe. Media inspectors such as MediaInfo show the GOP settings recorded by the encoder when they are available.
Common keyframe mistakes and trade-offs
- Setting a very short interval everywhere. Keyframes every few frames inflate files for no visible gain in a file that is only ever played straight through.
- Expecting frame-accurate stream-copy cuts. Without re-encoding, cuts snap to keyframes; plan cut points or accept a small re-encode.
- Streaming with scene-cut keyframes on when the platform wants a fixed interval, which can cause segment problems on some services.
- Trying to fix a long interval by remuxing. Changing the container never changes the frame structure; only re-encoding does.
- Using open GOPs for footage that will be spliced, so frames at the start of each piece are lost or concealed.
mydubly and keyframes
mydubly never re-encodes your picture. When it builds a translated video, the original video track is copied packet by packet into the new file next to the dubbed voice track, so the frames, frame types and keyframe positions are exactly those of your source. Seeking and scrubbing in the translated file therefore behave the way they did in the original, and the picture quality is unchanged.
That also means mydubly cannot improve an awkward keyframe structure. If you need a file that cuts or seeks precisely, re-export it from your editor with the interval you want before you start. Files can be up to 2 hours long; for anything longer, split it at keyframes first and process the parts separately, as described in translating long videos. The overall flow is in how to translate a video.
Next step: list your file's keyframes
Run the ffprobe command above on a video you edit or share often and look at the gaps between keyframe times. If they are a few seconds or less, the file will seek and cut comfortably; if they stretch to ten seconds or more and you need to trim, re-export once with a shorter interval before you trim, translate it with the mydubly video translator or hand it to an editor.
Frequently asked questions
What is a good keyframe interval?
It depends on the use. For live streaming, use the interval your platform asks for, commonly about 2 seconds. For a file you plan to cut later, 1 to 2 seconds works well, and for a finished file that will only be played, the encoder's default is usually fine.
Is keyframe interval the same as GOP size?
In everyday use, yes. Both describe the distance between keyframes, usually in frames, though some tools describe it in seconds. Strictly, a GOP is the group of frames itself and the interval is its length.
Does a shorter keyframe interval improve quality?
Not directly. At the same bitrate, more keyframes leave fewer bits for the other frames, which can lower quality slightly. Shorter intervals help with seeking, cutting, streaming and recovery from errors, not with how the picture looks.
Why do my cuts land a few seconds off?
Because the tool is cutting without re-encoding and can only start a clip on a keyframe. If the nearest keyframe is a few seconds before your chosen point, the clip starts there. Re-encoding at the cut, or exporting the source with shorter keyframe spacing, fixes it.
What is an IDR frame?
In H.264 and HEVC, an IDR frame is a keyframe that clears the decoder's memory of all earlier frames, so nothing after it can refer back past it. It is the cleanest possible starting point for decoding, which is why streaming segments and closed GOPs begin with one.
Can I change the keyframe interval without re-encoding?
No. Keyframe positions are part of how the video was compressed, so changing them means encoding the video again. Remuxing to another container keeps the existing frames exactly as they are.