Created
April 25, 2026 15:09
-
-
Save ejfox/7279174a741247af7b84d04f2c61bf12 to your computer and use it in GitHub Desktop.
Broadcast-normalize audio files to EBU R128 (-16 LUFS, -1 dBTP, 48kHz) with silence trimming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # broadcast-normalize-sfx.sh | |
| # Normalize audio files to broadcast-ready levels (EBU R128) | |
| # Strips leading silence, normalizes to -16 LUFS, limits peaks, resamples to 48kHz | |
| # | |
| # Usage: ./broadcast-normalize-sfx.sh <directory> | |
| # Requires: ffmpeg | |
| set -euo pipefail | |
| DIR="${1:-.}" | |
| cd "$DIR" || { echo "Error: cannot cd to $DIR"; exit 1; } | |
| echo "Processing all .mp3 files in: $(pwd)" | |
| echo "Target: -16 LUFS, -1 dBTP, 48kHz, leading silence removed, 200ms pad" | |
| echo "---" | |
| TOTAL=0 | |
| OK=0 | |
| FAIL=0 | |
| for f in *.mp3; do | |
| [ -f "$f" ] || continue | |
| TOTAL=$((TOTAL + 1)) | |
| echo "[$TOTAL] $f" | |
| TMPFILE=$(mktemp /tmp/broadcast-norm-XXXXXX.mp3) | |
| if ffmpeg -i "$f" \ | |
| -af "silenceremove=start_periods=1:start_duration=0:start_threshold=-40dB,loudnorm=I=-16:TP=-1:LRA=11,adelay=200|200" \ | |
| -ar 48000 -y "$TMPFILE" 2>/dev/null; then | |
| mv "$TMPFILE" "$f" | |
| OK=$((OK + 1)) | |
| echo " -> done" | |
| else | |
| rm -f "$TMPFILE" | |
| FAIL=$((FAIL + 1)) | |
| echo " -> FAILED" | |
| fi | |
| done | |
| echo "---" | |
| echo "Complete: $OK/$TOTAL succeeded, $FAIL failed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment