Skip to content
FramesField
SKILL.md Developer / Local Tooling SKILL.md
Verified Nov 30, 2026

FFmpeg Scene Detection and Contact Sheet Skill

How to install this SKILL.md

Install into .claude/skills/, .cursor/skills/, or .agents/skills/ below whenever you want your agent to slice footage on cuts, grab lossless keyframes, or build visual contact sheets for QA.

Installable SKILL.md teaching Claude Code, Cursor, and Codex how to detect shot cuts with FFmpeg, extract lossless PNG first/last keyframes for Image-to-Video continuity, and generate compact tiled contact sheets so vision agents can inspect entire video sequences in one image.

Compatible agent hosts
Claude Code Cursor Codex
Target tool: FFmpeg / ffprobe · License: MIT
  1. STEP 01
    Install the contact-sheet SKILL.md

    Pick Claude Code, Cursor, or Codex below and download the pure raw SKILL.md file.

  2. STEP 02
    Ask your agent to inspect a clip or extract frames

    Prompt e.g. 'Build a 3×2 contact sheet from ./renders/take1.mp4 and extract the exact opening and final frames as PNGs.'

  3. STEP 03
    Feed clean PNGs into QA or Dual-Keyframe I2V

    Review every beat at a glance or pass lossless extracted frames directly into Gemini Omni Flash or Luma Ray 3.2 start/end-frame bridges.

1. Install for your tool

Pick the app you use below for the exact verified command or config—zero manual guessing.

Direct raw file (SKILL.md) ↓
Claude Code (.claude/skills/) bash
Installs directly into .claude/skills/ffmpeg-contact-sheet/SKILL.md.
mkdir -p .claude/skills/ffmpeg-contact-sheet
curl -fsSL https://framesfield.com/raw/skills/ffmpeg-scene-cut-and-contact-sheet-skill -o .claude/skills/ffmpeg-contact-sheet/SKILL.md

2. Inspect or download the full SKILL.md file

This is the exact raw file served at /raw/skills/ffmpeg-scene-cut-and-contact-sheet-skill.

FFmpeg Scene Detection and Contact Sheet Skill SKILL.md
---
name: ffmpeg-contact-sheet
description: Detect scene cuts, extract lossless PNG opening and closing keyframes, and render tiled visual contact sheets from AI video clips using local ffmpeg and ffprobe for visual QA and I2V continuity.
---

# FFmpeg Scene Detection, Keyframe Extraction & Contact Sheet Protocol

Use these verified local FFmpeg patterns whenever inspecting generated video takes, extracting exact transition frames, or auditing multi-shot edits:

## 1. Build a Visual Inspection Contact Sheet (Single Image QA)
Sample frames evenly across a 5–10s clip into one crisp tiled PNG so a human or vision-capable agent can spot morphing, warped hands, or drift in one glance:
```bash
# Example: 2 fps across a 3s clip -> 6 tiles (3x2 grid) at 320px wide each
ffmpeg -y -i clip.mp4 \
  -vf "fps=2,scale=320:-2:flags=lanczos,tile=3x2:padding=4:margin=4:color=black" \
  -frames:v 1 contact_sheet.png
```
For longer 8–10s clips, use `fps=1,scale=360:-2:flags=lanczos,tile=4x3:padding=4:margin=4:color=black`.

## 2. Extract Exact Lossless Opening & Closing Frames (PNG)
Never JPEG-compress keyframes intended for Image-to-Video or First/Last Frame transitions:
```bash
# First frame (frame 0)
ffmpeg -y -i clip.mp4 -vf "select=eq(n\,0)" -vframes 1 first_frame.png

# Final frame (fast reverse-seek from EOF)
ffmpeg -y -sseof -0.15 -i clip.mp4 -update 1 -frames:v 1 last_frame.png
```

## 3. Detect Hard Scene Cuts Programmatically
Log timestamps where scene score crosses `0.35` (raise to `0.45` for fast action, lower to `0.25` for subtle studio cuts):
```bash
ffmpeg -i edit.mp4 -vf "select='gt(scene,0.35)',showinfo" -f null - 2>&1 \
  | grep "pts_time:"
```

## 4. Continuity Rule Warning
If extracting `last_frame.png` from an MP4 to extend a sequence, warn the user that chaining compressed MP4 frames more than 2 hops compounds VAE softening—prefer branching from pristine Level-0 PNG stills whenever character identity matters.

3. Test it right away (sample prompt & result)

Sample prompt / input
"Generate a 3x2 contact sheet for ./renders/shot02_kling.mp4 so I can check for label warping, and extract the exact final frame as ./keyframes/shot02_end.png."
What happens when it runs
- Runs verified `tile=3x2` lanczos filter -> outputs crisp `contact_sheet.png` for instant visual QA.
- Extracts lossless `shot02_end.png` via `-sseof -0.15 -update 1 -frames:v 1`.
- Reports frame dimensions and reminds about Level-0 Star-Branching if chaining further character shots.

What you need & known limits

Requirements

  • FFmpeg and ffprobe available on PATH (tested on FFmpeg 6.x–9.x including stock macOS Homebrew)
  • Claude Code, Cursor, or Codex with terminal access

Watch out for

  • Fixed fps= sampling can miss a 1-frame glitch between samples; increase fps or inspect cut boundaries explicitly for flagship spots
  • Scene-change threshold (0.35) does not trigger on slow cross-dissolves—only hard cuts

Frequently Asked Questions

Why generate a contact sheet instead of opening every MP4 in QuickTime?
A single 3×2 or 4×3 tiled PNG lets both human directors and multimodal coding agents inspect 6 to 12 moments across a clip simultaneously—catching mid-clip hand morphing or logo shimmer in seconds.
Why use -sseof -0.15 to grab the last frame?
Seeking backward 150 milliseconds from End-of-File avoids decoding the entire video from frame 0 and guarantees -update 1 overwrites cleanly with the final valid decoded frame.
Use this page in AI tools or notes
raw .md