---
name: ffmpeg-grain-lut-match
description: Unify AI video clips generated across mixed engines (Gemini Omni Flash, Kling 4.0, Runway, Wan 2.2) using restrained Rec.709 color balance, optional .cube 3D LUTs, organic temporal film grain, and explicit BT.709 yuv420p metadata tags in FFmpeg.
---

# FFmpeg Multi-Model Color Matching & Organic Grain Protocol

When blending shots from different AI video engines, differences in skin smoothing, saturation, and noise floor make cuts feel synthetic. Apply this deterministic finishing pass AFTER concatenation (never add grain twice to the same clip):

## 1. Default Editorial Unifying Pass (No External LUT Required)
Slightly reins in oversaturated AI greens/oranges (`saturation=0.96`), anchors contrast (`1.03`), and overlays subtle uniform temporal 35mm-style grain (`alls=6` to `8`, `allf=t+u`):
```bash
ffmpeg -y -i assembled_master.mp4 \
  -vf "eq=contrast=1.03:saturation=0.96:brightness=0.01,noise=alls=7:allf=t+u,format=yuv420p" \
  -c:v libx264 -preset slow -crf 18 \
  -colorspace bt709 -color_primaries bt709 -color_trc bt709 \
  -c:a copy -movflags +faststart \
  unified_rec709_master.mp4
```

## 2. Applying a Studio `.cube` 3D LUT at Controlled Strength
Never bake heavy creative LUTs at 100% blind opacity—allow blending with the original footage (e.g., `50%` LUT opacity via `split` + `blend` or restrained neutral LUT) followed by uniform grain:
```bash
ffmpeg -y -i assembled_master.mp4 \
  -filter_complex "
    [0:v]split=2[orig][tolut];
    [tolut]lut3d=file=studio_rec709.cube:interp=tetrahedral[lutted];
    [orig][lutted]blend=all_expr='A*0.5+B*0.5',noise=alls=6:allf=t+u,format=yuv420p[vout]
  " \
  -map "[vout]" -map 0:a? \
  -c:v libx264 -preset slow -crf 18 \
  -colorspace bt709 -color_primaries bt709 -color_trc bt709 \
  -c:a copy -movflags +faststart \
  graded_lut_master.mp4
```

## 3. Restraint & Compression Rules
- Keep `noise=alls` strictly between `5` and `9` (`>12` looks noisy and destroys H.264 bitrate efficiency on YouTube/Reels).
- Always set `-crf 17` or `-crf 18` when adding grain so the H.264 encoder preserves fine texture instead of smearing grain into macroblocks.
- Always tag `-colorspace bt709 -color_primaries bt709 -color_trc bt709` so macOS QuickTime and Chrome render identical gamma.
