# FFmpeg Studio Conform & Loudness Skill

> Drop-in SKILL.md instruction file for Claude Code, Cursor, and Codex agents to inspect raw AI video renders via ffprobe, standardize mixed frame rates (16/24/30 fps), normalize audio strictly to EBU R128 (-14 LUFS / -1.0 dBTP), and concatenate delivery masters without A/V drift.

- **Canonical URL:** https://framesfield.com/skills/ffmpeg-loudness-conform
- **Asset Type:** SKILL.md
- **Compatible Hosts:** Claude Code, Cursor, Codex
- **Target Creative Tool:** FFmpeg
- **License:** MIT
- **Last Verified:** 2026-11-26
- **Source Reference:** https://ffmpeg.org/ffmpeg-filters.html#loudnorm

## Setup & Install

```bash
mkdir -p .agents/skills/ffmpeg-studio-conform
curl -fsSL https://framesfield.com/skills/ffmpeg-loudness-conform.md -o .agents/skills/ffmpeg-studio-conform/SKILL.md

```

## Copyable Asset (SKILL.md)

```markdown
---
name: ffmpeg-studio-conform
description: Inspect, conform mixed AI video clips (Veo, Kling, Wan, Runway) to a unified frame rate and color space, normalize loudness to EBU R128 (-14 LUFS), and build deterministic delivery masters using local ffprobe and ffmpeg.
---

# FFmpeg Studio Conform Protocol

Follow these exact rules whenever the user asks to splice, conform, resize, or master video clips.

## 1. Always Probe First (Never Guess Stream Specs)
Before generating any ffmpeg command, run `ffprobe` on every input clip to verify width, height, frame rate, pixel format, and presence of an audio stream:
```bash
ffprobe -v error -show_entries stream=codec_type,codec_name,width,height,r_frame_rate,pix_fmt,sample_rate,channels -of json "<input>"
```

## 2. Handle Silent Clips Explicitly
AI video outputs from Runway Gen-4 Turbo or Wan 2.2 lack an audio stream. Never run `-f concat` mixing audio-bearing clips (Veo 3.1 / Kling 2.6) with silent clips; synthesize matching silent stereo PCM first:
```bash
ffmpeg -y -i silent_clip.mp4 -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 \
  -shortest -c:v copy -c:a pcm_s16le silent_with_audio.mov
```

## 3. Intermediate Conform Standard
Transcode every heterogeneous clip to identical mezzanine properties before concatenation:
- Video: `1920x1080` (or `1080x1920` for 9:16), `fps=24`, `setsar=1`, `yuv420p`, `libx264 -crf 15`
- Audio: `pcm_s16le`, `48000 Hz`, `2 channels (stereo)`

## 4. Two-Pass Loudness Normalization (-14 LUFS)
Measure integrated loudness first, then apply linear normalization in pass 2:
```bash
ffmpeg -i concat_master.mov -af "loudnorm=I=-14:TP=-1.0:LRA=11:print_format=json" -f null -
```
Feed measured `input_i`, `input_tp`, `input_lra`, and `input_thresh` into pass 2 with `linear=true` and export with `-movflags +faststart`.

## 5. Verification Checklist
After export, run `ffprobe` on the final master and report exact duration, resolution, frame rate, codec, and measured LUFS to the user.
```

## Example Input

```text
"Conform all 4 MP4 files in ./shots/ (two Veo 3.1 24fps dialogue clips and two silent Runway Gen-4 720p clips) into a single 1080p 24fps master at -14 LUFS with a 0.25s black fade-out."
```

## Expected Output

```text
1. Runs ffprobe across ./shots/*.mp4 and outputs a stream audit table (identifies 2 silent streams + 720p upscale needed).
2. Injects 48kHz stereo anullsrc tracks into the 2 silent Gen-4 clips and normalizes all 4 clips to 1920x1080 @ 24fps PCM mezzanine MOVs.
3. Runs pass-1 loudnorm analysis, prints measured LUFS/True Peak, and executes pass-2 linear loudnorm render to ./master_1080p_24fps.mp4.
4. Verifies output duration (24.00s), yuv420p, and -14.0 LUFS target.
```

## Requirements

- FFmpeg 6.1+ and ffprobe available on system PATH (`brew install ffmpeg` on macOS)
- Local filesystem read/write shell access in Claude Code, Cursor, or Codex
- Sufficient scratch disk space for lossless PCM mezzanine clips (~120MB per minute)

## Known Limits

- Does not perform optical-flow speed ramping automatically unless explicitly instructed to use minterpolate
- HDR10 / HLG Rec.2020 inputs require an explicit zscale/tonemap LUT stage before Rec.709 delivery

## Implementation Notes

## Why agents fail at FFmpeg without a strict protocol

Left unguided, coding agents reach for single-pass `-f concat -c copy` commands that silently break whenever a silent Runway or Wan 2.2 render is spliced beside a dialogue-bearing Veo 3.1 clip. Enforcing a **probe-first -> mezzanine conform -> two-pass R128** protocol guarantees deterministic, broadcast-safe exports on the first execution.
