---
name: ffmpeg-vertical-delivery
description: Produce unified 1080x1920 vertical Reels, Shorts, and TikTok masters with cross-platform safe-zone ASS captions, voice-triggered music sidechain ducking (preserving silent end-cards with apad), and -14 LUFS EBU R128 loudness conform.
---

# FFmpeg 9:16 Vertical Delivery & Audio Ducking Rules

Whenever asked to render, crop, subtitle, or mix vertical short-form video (TikTok, Instagram Reels, YouTube Shorts), enforce ALL five invariants below:

## 1. Probe FFmpeg Subtitle Support First (macOS Homebrew Guard)
Stock Homebrew `ffmpeg` on macOS often omits `libass`. Always check filter support before burning captions:
```bash
ffmpeg -filters 2>/dev/null | grep -E " (ass|subtitles) "
```
- If `ass` is present: proceed with burned-in ASS captions below.
- If `ass` is missing: inform the user they can install full subtitle support (`brew install ffmpeg-full` on macOS) OR fall back cleanly to soft-muxed subtitles (`-i captions.srt -c:s mov_text`) while still running the 1080x1920 scale + sidechain audio ducking pipeline.

## 2. Canvas & Aspect Ratio Integrity
- Target canvas: exact `1080x1920` (`setsar=1`, `yuv420p`, `libx264`, `-crf 18`, `-movflags +faststart`).
- If input is already native `9:16`, scale directly (`scale=1080:1920:flags=lanczos`)—never add black bars.
- If input is `16:9` (warn user if source height < 2160p about 68.4% pixel loss), center-crop cleanly: `scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1`.

## 3. Unified 1080x1920 Cross-Platform Subtitle Safe Band (ASS Format)
Convert `.srt` to `.ass` and inject this exact `[V4+ Styles]` header so captions stay inside `y: 1220–1420 px` and clear of the right `150px` action rail:
```ini
[Script Info]
ScriptType: v4.00+
PlayResX: 1080
PlayResY: 1920
WrapStyle: 2

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: VerticalSafe,Arial,62,&H00FFFFFF,&H002044E0,&H00111111,&H80000000,-1,0,0,0,100,100,0,0,1,3,1,2,80,170,520,1
```
- Wrap dialogue cues to 3–4 words max per line.

## 4. Sidechain Auto-Ducking + `apad` End-Card Guard + 48 kHz Conform
Always include `apad` on the voiceover chain so `-shortest` ends cleanly at the full video length rather than cutting off silent closing brand end-cards when narration finishes early:
```bash
# With libass installed (omit `,ass=captions.ass` if running without burned captions):
ffmpeg -y -i input_video.mp4 -i voice.wav -stream_loop -1 -i music.mp3 \
  -filter_complex "
    [0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1,ass=captions.ass[vout];
    [1:a]aresample=48000,highpass=f=80,dynaudnorm=f=150:g=15,apad,asplit=2[vo_mix][vo_sc];
    [2:a]aresample=48000,volume=-14dB[bed_base];
    [bed_base][vo_sc]sidechaincompress=threshold=0.025:ratio=4.5:attack=25:release=300:makeup=1[bed_ducked];
    [vo_mix][bed_ducked]amix=inputs=2:duration=first:dropout_transition=2:normalize=0,
    loudnorm=I=-14:TP=-1.0:LRA=7[aout]
  " \
  -map "[vout]" -map "[aout]" \
  -r 24 -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p \
  -c:a aac -b:a 192k -ar 48000 -ac 2 \
  -shortest -movflags +faststart \
  vertical_master_1080x1920.mp4
```

## 5. Verification Before Returning
Always verify the rendered master with `ffprobe -v error -show_entries format=duration -show_entries stream=width,height,r_frame_rate,pix_fmt,sample_rate -of default=noprint_wrappers=1 vertical_master_1080x1920.mp4` and confirm full video duration was preserved.
