What a keyframe is
A video stores a keyframe as a full image. The frames after it store only what changed. A player can start playback, or jump to a new time, only at a keyframe. The group of frames from one keyframe to the next is a group of pictures, or GOP. The GOP size is the number of frames in that group.
Long intervals give smaller files, because full images use more data. Short intervals make seeking faster and let a stream start sooner.
Recommended keyframe intervals
| Platform | Keyframe interval | Notes |
|---|---|---|
| YouTube Live | 2 seconds | Do not go above 4 seconds |
| Twitch | 2 seconds | A fixed interval |
| Apple HLS | 2 seconds | Each segment must start with a keyframe |
| Video on demand files | 2 to 10 seconds | Longer intervals give smaller files |
At 30 frames per second, 2 seconds is a GOP size of 60 frames. At 60 frames per second, it is 120 frames.
Fixed or variable GOP
Most encoders add a keyframe at each scene cut by default. This gives a variable GOP: the intervals change through the video. That is good for file quality, but it causes problems for live streaming and HLS, where the segments must all start with a keyframe at the same rhythm. This tool shows the shortest and the longest interval, so you can see a variable GOP at once.
The sample video shows this. It has a keyframe every 2 seconds, plus extra keyframes at its scene cuts. To find the cuts in your own video, use the free scene detection tool. To learn more about cuts, see shot detection.
How to fix the keyframe interval
Re-encode the video with a fixed GOP. For a 2-second interval at 30 fps, use this command:
ffmpeg -i input.mp4 -c:v libx264 -g 60 -keyint_min 60 -sc_threshold 0 -c:a copy output.mp4
-g 60sets the longest GOP to 60 frames.-keyint_min 60sets the shortest GOP to 60 frames.-sc_threshold 0stops the extra keyframes at scene cuts.
The tool makes this command for the frame rate of your file, with the target that you choose.
How the tool works
The tool reads the container of your video with WebCodecs and Mediabunny. It reads only the frame headers, not the pictures, so it is fast, even for a long file. It marks each frame as a keyframe or a delta frame. For other details about the file, such as the codec and the bitrate, use the video metadata viewer.