Ffmpeg keyframes
Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-sonnet-4-6/video-object-counting/ffmpeg-keyframes
[COLM'26] SkillLearnBench is the first benchmark for evaluating continual learning methods that automatically generate agent skills.
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.
What its author says it does
Copied from the file, not written here
Extract I-frame keyframes from video files using FFmpeg command line, saving them as numbered PNG images.
SKILL.md
1.6 KB, 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