Keyframe interval explained: I-frames, GOPs, and cuts

The keyframe interval is how far apart a video's whole-picture frames sit. It decides where copy cuts and fast seeks land. How to read and set it.

5 min readSume
All posts

The keyframe interval is the distance between a video's keyframes, the frames it stores as complete pictures. The frames in between store only changes, so decoding has to start at a keyframe, and a cut without re-encoding or a fast seek can only land on one. The interval is set when the video is encoded, and it's also called the GOP (group of pictures) size.

The FFmpeg facts come from its ffmpeg, codecs, and ffprobe documentation, and Sume's behavior from the Video trim and Video inspect docs and the Sume API reference, read on 2026-09-28. Anything described as current behavior is read from Sume's code.

What are I-frames, P-frames, and B-frames?

A keyframe is an I-frame. The frames after it, up to the next keyframe, store changes instead, as P- or B-frames, and together they make up one group of pictures (GOP):

  • I-frame (keyframe): a complete picture that decodes on its own.
  • P-frame: stores the changes from an earlier frame.
  • B-frame: stores changes relative to frames on both sides of it, before and after.
  • In FFmpeg's libx264 options, -g (x264's keyint) is the maximum GOP size, -keyint_min (min-keyint) is the minimum GOP size, and -bf (bframes) is the number of B-frames between I- and P-frames.

Why does the keyframe interval matter?

It sets how close to your mark a cut or a jump can land without decoding: a cut made by stream copy opens on the keyframe at or before your in-point, up to one interval early, while a re-encoded cut decodes from that keyframe and discards the frames before your mark. FFmpeg trim video shows both with FFmpeg's -ss.

Sume's media tools show both sides of that trade-off. They read only your workspace's media.sume.com files, such as an earlier Sume job's output:

From Video trim and Video inspect, read 2026-09-28.
Sume operationWhat the keyframe interval does to it
Video trim, precision: "keyframe"A stream copy with no re-encode. The cut may start a GOP early, and the result's actual_start_seconds says where it really starts.
Video trim, precision: "exact" (the default)A frame-accurate re-encode (libx264, yuv420p), so the source's keyframes don't limit the cut.
Video inspect stills, seek: "fast"Each still snaps to the keyframe at or before its instant: earlier by up to one GOP (roughly 0–5 s on typical sources), never later.
Video inspect stills, seek: "precise" (the default)Decodes to the exact instant.

What keyframe interval do Sume's encodes use?

In current code, a compose and a Timeline render set -g and -keyint_min to the output frame rate, and an exact trim and a video filter set them to the source's frame rate, rounded, when that rate is known. So their keyframes are at most about one second apart, unless a trim's output.fps or a filter program lowers the frame rate. A later keyframe trim of such a file therefore starts at most about a second early. Split a long video into short clips shows when to pick each trim precision.

How do I set the keyframe interval with FFmpeg?

Set it when you encode. With libx264, -g caps the GOP in frames, so multiply the frame rate by the seconds you want: -g 48 at 24 fps means a keyframe at least every 2 seconds. -force_key_frames places keyframes by time instead, and FFmpeg's docs use expr:gte(t,n_forced*5) to force one every 5 seconds.

  • -g is a maximum, so the encoder may still place keyframes closer together.
  • FFmpeg's docs warn that forcing too many keyframes is very harmful for the lookahead algorithms of certain encoders, and that fixed-GOP options or similar would be more efficient.
  • Both commands re-encode the video. A stream copy keeps the source's keyframes exactly where they are.
# At most 48 frames (2 s at 24 fps) between keyframes
ffmpeg -i input.mp4 -c:v libx264 -g 48 -c:a copy output.mp4

# A keyframe every 5 seconds, by time
ffmpeg -i input.mp4 -c:v libx264 -force_key_frames "expr:gte(t,n_forced*5)" -c:a copy output.mp4

How do I see where a video's keyframes are?

Sume's free probe, POST /v1/video-inspect with frames: false, reports a clip's codec, size, and frame rate, but it has no keyframe field, so check the file with ffprobe.

Ask ffprobe for keyframe timestamps only. The skip_frame decoder option with nokey discards all frames except keyframes, so this command prints one time per keyframe, and the gaps between the times are the interval:

ffprobe -v error -skip_frame nokey -select_streams v:0 \
  -show_entries frame=pts_time \
  -of default=noprint_wrappers=1:nokey=1 input.mp4

Sources

Related posts

More in Media tools

All Media tools posts

Written by Sume