---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://framesfield.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
title: "FFmpeg Scene Detection and Contact Sheet Skill"
description: "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."
canonical: "https://framesfield.com/skills/ffmpeg-scene-cut-and-contact-sheet-skill"
---

# FFmpeg Scene Detection and Contact Sheet Skill

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

- **Canonical URL:** https://framesfield.com/skills/ffmpeg-scene-cut-and-contact-sheet-skill
- **Raw Payload URL:** https://framesfield.com/raw/skills/ffmpeg-scene-cut-and-contact-sheet-skill
- **Asset Type:** SKILL.md
- **Compatible Hosts:** Claude Code, Cursor, Codex
- **Target Creative Tool:** FFmpeg / ffprobe
- **License:** MIT
- **Last Verified:** 2026-11-30
- **Source Reference:** https://ffmpeg.org/ffmpeg-filters.html#tile

## Setup & Install

```bash
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

```

## Copyable Asset (SKILL.md)

````markdown
---
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.
````

## Example Input

```text
"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."
```

## Expected Output

```text
- 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.
```

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

## Known Limits

- 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

## Implementation Notes

## Combine with Dual-Keyframe & QA workflows

Pair extracted keyframes with [Workflow 10: Locked First-and-Last Frame Match-Cut Sequence](/workflows/first-last-frame-transition-sequence) and use contact sheets inside [Skill 25: Thumbnail and First-3s Hook Auditor Subagent](/skills/thumbnail-and-hook-auditor-agent).
