Skip to content

/glossary/ffmpeg/keyframe

What is a keyframe (I-frame) in video?

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · ffmpeg version 9.0.2-full_build-www.gyan.devupdated 2026-10-20
tool
FFmpeg
versions
any
os
any

A keyframe (I-frame, intra frame) is a complete picture encoded without reference to any other frame. The frames between keyframes (P- and B-frames) store only differences from their neighbours, which is where most of the compression comes from. A decoder can start playing only at a keyframe, so they determine where seeking lands and where -c copy cuts can begin.

See where the keyframes are

-g 10 asks the encoder for a keyframe at least every 10 frames:

bash
ffmpeg -hide_banner -loglevel error -f lavfi -i testsrc=size=320x240:rate=10:duration=3 -c:v libx264 -g 10 -bf 0 -pix_fmt yuv420p -y gop.mp4
ffprobe -v error -select_streams v -show_entries frame=pict_type -of csv=p=0 gop.mp4 | paste -sd' '

Output

I,
 P
 P
 P
 P
 P
 P
 P
 P
 P
 I
 P
 P
 P
 P
 P
 P
 P
 P
 P
 I
 P
 P
 P
 P
 P
 P
 P
 P
 P

I marks keyframes; with -g 10 at 10 frames per second there is one per second.

TermMeaning
I-frameintra-coded, self-contained (a keyframe)
P-framepredicted from earlier frames
B-framepredicted from earlier and later frames
GOPgroup of pictures: a keyframe and the frames up to the next one
-g Nmaximum GOP length in frames
-force_key_frameskeyframes at given times, for example every 2 s for HLS segments

Short GOPs make seeking and stream copy cuts more precise but cost bitrate; streaming services commonly use a keyframe every 2 seconds.

Sources