---
name: loudness-fix
description: One-shot audio mastering to streaming loudness targets (Spotify -14 LUFS, Apple Music -16, YouTube -14, broadcast -23). Two-pass ffmpeg loudnorm with true-peak limiting, preserves original quality. Works on audio files OR the audio track of a video. Use when the user asks to "master this", "fix the loudness", "make it Spotify-ready", "normalize for streaming", says a track is too quiet/loud, or needs LUFS-compliant audio for upload.
---


# loudness-fix

Two-pass `ffmpeg loudnorm` mastering. Targets the standard for whichever platform you name. True-peak limited so it won't clip on lossy codecs.

## Master to a platform preset

```bash
python3 ~/.claude/skills/loudness-fix/scripts/fix.py --input track.wav --target spotify
# → track_mastered.wav at -14 LUFS, true peak -1 dBTP
```

Presets:
- `spotify` → -14 LUFS, TP -1 (default)
- `apple` → -16 LUFS, TP -1
- `youtube` → -14 LUFS, TP -1
- `tidal` → -14 LUFS, TP -1
- `broadcast` → -23 LUFS, TP -2 (EBU R128)
- `club` → -9 LUFS, TP -1 (loud, modern hip-hop / EDM)

## Custom target

```bash
python3 ~/.claude/skills/loudness-fix/scripts/fix.py --input track.wav --lufs -12 --tp -1
```

## Video files (re-mux audio at new loudness)

```bash
python3 ~/.claude/skills/loudness-fix/scripts/fix.py --input music_video.mp4 --target spotify
# → music_video_mastered.mp4 (video copy, audio loudness-fixed)
```

## Flags

- `--input` — audio or video file
- `--target` — preset name (default `spotify`)
- `--lufs` — override integrated loudness target
- `--tp` — override true-peak ceiling (dBTP)
- `--lra` — override loudness range (LU)
- `--output` — output file (default `<name>_mastered.<ext>`)
- `--codec` — output audio codec (default: wav for audio inputs, aac@320k for video)

## How it works

1. Pass 1: ffmpeg analyzes the file with `loudnorm=print_format=json` → measured LUFS/TP/LRA
2. Pass 2: ffmpeg applies the loudnorm filter using the measured values for accurate linear normalization (better than single-pass dynamic mode)
3. For video, the video stream is `-c:v copy`'d (no re-encode) and only the audio is touched

## Pairs well with

- `stems` — master each stem before recombining
- `cover-art` + `loudness-fix` → release-ready single
