home / skills / benchflow-ai / skillsbench / ffmpeg

This skill extracts I-frames from video files using FFmpeg for thumbnails, previews, or analysis, delivering fast, reliable keyframe extraction.

npx playbooks add skill benchflow-ai/skillsbench --skill ffmpeg

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.9 KB
---
name: ffmpeg-keyframe-extraction
description: Extract key frames (I-frames) from video files using FFmpeg command line tool. Use this skill when the user needs to pull out keyframes, thumbnails, or important frames from MP4, MKV, AVI, or other video formats for analysis, previews, or processing.
license: Complete terms in LICENSE.txt
---

# 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.)

## Methods

### Method 1: Select Filter (More Control)

```bash
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
-q:v <n>	Quality (1-31, lower = better, for JPEG)
-frame_pts 1	Use presentation timestamp in filename
Output Patterns
frame_%03d.png - PNG sequence (frame_001.png, frame_002.png...)
frame_%03d.jpg - JPEG sequence
frame_%d.bmp - BMP sequence
Examples
Basic PNG extraction:
```
ffmpeg -i video.mp4 -vf "select='eq(pict_type,I)'" -vsync vfr keyframe_%03d.png
High-quality JPEG:
```

```
ffmpeg -i video.mp4 -skip_frame nokey -vsync vfr -q:v 2 keyframe_%03d.jpg
With timestamps:
```

```
ffmpeg -i video.mp4 -vf "select='eq(pict_type,I)'" -vsync vfr -frame_pts 1 keyframe_%d.png
```

To specific directory:

```
ffmpeg -i video.mp4 -vf "select='eq(pict_type,I)'" -vsync vfr ./output/keyframe_%03d.png
```

## Notes
Method 2 (-skip_frame nokey) is faster as it skips decoding non-keyframes
Method 1 offers more filtering flexibility (can combine with other filters)
Keyframe frequency depends on video encoding settings
Use -vsync vfr to avoid duplicate frames in output

Overview

This skill extracts key frames (I-frames) from video files using the FFmpeg command line tool. It produces image sequences (PNG, JPEG, BMP) or timestamped frames for use as thumbnails, previews, or inputs to analysis pipelines. The skill supports both precise filtering and faster skipping methods to balance control and performance.

How this skill works

The skill runs FFmpeg commands that either select I-frames via the select filter (vf "select='eq(pict_type,I)'") or skip non-keyframes during decoding (-skip_frame nokey). It uses -vsync vfr to emit a variable frame rate stream and avoid duplicate output frames. Optional flags include -q:v to control JPEG quality and -frame_pts to name files by presentation timestamp.

When to use it

  • Generate thumbnails or contact sheets from videos for UI/UX previews
  • Extract representative frames for computer vision or manual analysis
  • Create image datasets of key moments without decoding every frame
  • Produce high-quality JPEGs for web display or PNGs for lossless inspection
  • Save frames with timestamps for synchronization or forensic review

Best practices

  • Prefer -skip_frame nokey for large files when speed matters; use select filter when you need additional filtering or combinations
  • Always include -vsync vfr to prevent duplicate frames in the output sequence
  • Set -q:v (1–31) for JPEG quality; lower numbers give better quality and larger files
  • Use -frame_pts 1 to include presentation timestamps in filenames for easy alignment with original media
  • Write output to a dedicated directory and use a clear naming pattern like keyframe_%03d.png to avoid collisions

Example use cases

  • Create a folder of thumbnail PNGs from an MP4 to use in a video gallery: ffmpeg -i video.mp4 -vf "select='eq(pict_type,I)'" -vsync vfr ./out/keyframe_%03d.png
  • Rapidly extract key JPEGs for large archives: ffmpeg -i archive.mkv -skip_frame nokey -vsync vfr -q:v 2 keyframe_%03d.jpg
  • Produce timestamped frames for logging or QA: ffmpeg -i clip.mov -vf "select='eq(pict_type,I)'" -vsync vfr -frame_pts 1 keyframe_%d.png
  • Combine keyframe selection with other filters (scale, crop) by using the select filter and chained FFmpeg filters

FAQ

Do I need FFmpeg installed?

Yes. This skill runs FFmpeg commands, so FFmpeg must be installed and available in your PATH.

Which method is faster: select filter or -skip_frame nokey?

-skip_frame nokey is faster because it skips decoding non-keyframes. The select filter provides more flexibility when combining with other filters.