Media ffmpeg normalize

From damionrashford/media-os · View interactive version

Media ffmpeg normalize is an AI agent skill from the GitHub repository damionrashford/media-os. Higher-level EBU R128 loudness normalization with ffmpeg-normalize: 2-pass loudnorm batch wrapper, target loudness/TP/LRA, preserves streams, works across directories, output format selection, dry-run plan. Use when the user asks to batch-normalize audio loudness, apply EBU R128 across many files, u

How to use this skill

Skill file

Media Ffmpeg Normalize

Context: $ARGUMENTS

ffmpeg-normalize is a Python wrapper around ffmpeg's loudnorm filter that automates proper 2-pass EBU R128 normalization, batch directories, and preserves non-audio streams. Raw loudnorm is 1-pass by default (dynamic, inaccurate); this tool does the measure-then-apply pass automatically.

Quick start

When to use

Step 1 — Install

pip install ffmpeg-normalize
# or with uv
uv tool install ffmpeg-normalize

Requires ffmpeg on PATH. Verify:

ffmpeg-normalize --version
ffmpeg -hide_banner -filters | grep loudnorm

Step 2 — Pick a target

Decide the three EBU R128 parameters:

| Flag | Meaning | Typical value |

|------|---------|---------------|

| -t | Integrated loudness (LUFS) | -23 broadcast EBU R128, -24 ATSC A/85, -16 Apple Podcasts, -14 YouTube/Spotify |

| -tp | True peak ceiling (dBFS) | -1.0 to -2.0 (use -1.5 as default) |

| -lrt | Loudness range target (LU) | 11 broadcast / podcast, omit for streaming (no clamp) |

Rule of thumb: broadcast = -23 LUFS, podcast = -16 LUFS, streaming = -14 LUFS. See references/normalize.md for the full platform table.

Step 3 — Batch

Single file:

ffmpeg-normalize input.mp3 -o output.mp3 -t -16 -tp -1.5 -lrt 11

Folder (glob expanded by shell):

ffmpeg-normalize in/*.mp3 -of out/ -t -16 -tp -1.5 -lrt 11 --progress

Video (copy video, re-encode audio — REQUIRED since raw can't be muxed back):

ffmpeg-normalize in.mp4 -c:a aac -b:a 192k -o out.mp4

The helper script:

uv run ${CLAUDE_SKILL_DIR}/scripts/normalize.py preset --input in.mp3 --output out.mp3 --platform apple-podcasts
uv run ${CLAUDE_SKILL_DIR}/scripts/normalize.py batch --indir episodes/ --outdir normalized/ --platform spotify

Dry-run first:

ffmpeg-normalize in.mp3 -o out.mp3 --dry-run

Step 4 — Verify

Measure the output to confirm it hit the target:

ffmpeg -i out.mp3 -af ebur128=peak=true -f null - 2>&1 | tail -20
# Look for: I: (integrated LUFS), LRA, True peak

Or use --print-stats / --debug during the normalize run to emit per-file loudnorm JSON.

Available scripts

Reference docs

Gotchas

Examples

Example 1: Podcast library to Apple Podcasts spec

ffmpeg-normalize podcast/*.mp3 \
  -of podcast-normalized/ \
  -t -16 -tp -1.5 -lrt 11 \
  -c:a libmp3lame -b:a 192k \
  --progress

Example 2: Video for YouTube (keep video, AAC audio)

ffmpeg-normalize talk.mp4 \
  -t -14 -tp -1.0 \
  -c:a aac -b:a 192k \
  -o talk-yt.mp4

Example 3: Dry-run across a directory (plan only)

ffmpeg-normalize *.wav -of out/ -t -23 --dry-run --print-stats

Example 4: Only lower (never boost) for a noisy archive

ffmpeg-normalize noisy/*.wav -of safe/ -t -23 --lower-only

Example 5: Specific audio stream (e.g., second language track only)

ffmpeg-normalize in.mkv -o out.mkv --audio-stream-filter "a:1" -c:a aac

Troubleshooting

Error: `Output file does not contain any stream` or missing audio in MP4

Cause: Default codec pcm_s16le can't be muxed into MP4.

Fix: Add -c:a aac -b:a 192k (or -c:a libmp3lame for MP3 output).

Output is quieter than expected

Cause: Default target is -23 LUFS (broadcast). Streaming targets are louder.

Fix: Use -t -14 (YouTube/Spotify) or -t -16 (Apple Podcasts).

All files in a batch sound different relative to each other

Cause: Expected — each file is normalized to the target independently. Quiet originals get boosted to target; loud originals get cut.

Fix: Use manual 2-pass loudnorm with a single concatenated measurement, or process all files together via the ffmpeg-audio-filter skill.

True peak still clips on consumer device

Cause: -tp default is -2 but inter-sample peaks can still exceed on some chains.

Fix: Tighten to -tp -1.5 or -tp -2.0; do not go above -1.0.

`RuntimeError: Could not find ffmpeg`

Cause: ffmpeg not on PATH.

Fix: Install ffmpeg (brew install ffmpeg on macOS) or set FFMPEG_PATH=/path/to/ffmpeg.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.