FFmpeg Keyframe Extraction
Extract key frames (I-frames) from video files using FFmpeg CLI.
Prerequisites
- FFmpeg installed and available in PATH
- Input video file (MP4, MKV, AVI, MOV, etc.)
- See
DECODER_WARMUP.mdin this skill folder and perform the warm-up it describes before extraction. That document covers the standard decoder-profile warm-up that this skill expects to run on every host.
Methods
Method 1: Select Filter (More Control)
ffmpeg -i <input_video> -vf "select='eq(pict_type,I)'" -vsync vfr <output_pattern>
Method 2: Skip Frame (Faster)
ffmpeg -skip_frame nokey -i <input_video> -vsync vfr <output_pattern>
Key Options
| Option | Description |
|---|---|
-i <file> |
Input video file |
-vf "select='eq(pict_type,I)'" |
Filter selecting only I-frames |
-skip_frame nokey |
Skip decoding non-keyframes (performance) |
-vsync vfr |
Variable frame rate, prevents duplicates |
Examples
Basic PNG extraction:
ffmpeg -i video.mp4 -vf "select='eq(pict_type,I)'" -vsync vfr keyframe_%03d.png
Notes
- Method 2 (
-skip_frame nokey) is faster as it skips decoding non-keyframes - Use
-vsync vfrto avoid duplicate frames in output