Ffmpeg keyframes
Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-sonnet-4-6/video-object-counting/ffmpeg-keyframes
Extract I-frame keyframes from video files using FFmpeg command line, saving them as numbered PNG images.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill ffmpeg-keyframesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.6 KB, 427 tokens by cl100k_base, as published. Nobody here has run it
FFmpeg Keyframe Extraction
Installation
sudo apt-get install ffmpeg
# or: conda install -c conda-forge ffmpeg
Extract All I-Frame Keyframes
ffmpeg -i input.mp4 -vf "select=eq(pict_type\,I)" -vsync vfr /output/keyframes_%03d.png
select=eq(pict_type\,I)— selects only I-frames (keyframes)-vsync vfr— variable frame rate to avoid duplicate frames%03d— zero-padded 3-digit frame numbering (001, 002, ...)
Extract Frames at Fixed Interval
ffmpeg -i input.mp4 -vf "fps=1" /output/frame_%03d.png # 1 frame per second
ffmpeg -i input.mp4 -vf "fps=0.5" /output/frame_%03d.png # 1 frame every 2 seconds
Get Video Info
ffprobe -v quiet -print_format json -show_streams input.mp4
Python Wrapper
import subprocess, glob, os
def extract_keyframes(video_path, output_dir, pattern="keyframes_%03d.png"):
os.makedirs(output_dir, exist_ok=True)
output_pattern = os.path.join(output_dir, pattern)
cmd = [
"ffmpeg", "-i", video_path,
"-vf", "select=eq(pict_type\\,I)",
"-vsync", "vfr",
output_pattern, "-y"
]
subprocess.run(cmd, check=True, capture_output=True)
frames = sorted(glob.glob(os.path.join(output_dir, "keyframes_*.png")))
return frames
Notes
- I-frames are self-contained frames, ideal as keyframes for analysis
- Output numbering starts at 1 by default (001, 002, ...)
- Use
-yto overwrite existing files without prompting
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.