Skip to content

Instantly share code, notes, and snippets.

@coulterpeterson
Last active March 17, 2026 12:45
Show Gist options
  • Select an option

  • Save coulterpeterson/bfaf3fe483791ad514309cf655aa1f12 to your computer and use it in GitHub Desktop.

Select an option

Save coulterpeterson/bfaf3fe483791ad514309cf655aa1f12 to your computer and use it in GitHub Desktop.
MacOS Normalize Video Audio for YouTube
#!/bin/bash
# Video Audio Normalization Script
# Place this file in /usr/local/bin/video-audio-normalize.sh
# Make executable with `sudo chmod +x /usr/local/bin/video-audio-normalize.sh`
# Usage (global): video-audio-normalize.sh myvideo.mp4
# Check if a file was provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <input_video_file>"
exit 1
fi
INPUT_FILE="$1"
# Check if the file exists
if [ ! -f "$INPUT_FILE" ]; then
echo "Error: File '$INPUT_FILE' not found."
exit 1
fi
# Extract the base name and extension to create the output filename
FILENAME=$(basename -- "$INPUT_FILE")
EXTENSION="${FILENAME##*.}"
NAME="${FILENAME%.*}"
# Get the directory of the input file
DIR=$(dirname "$1")
OUTPUT_FILE="${DIR}/${NAME}_normalized.${EXTENSION}"
echo "Processing: $INPUT_FILE"
echo "Target: -14 LUFS, -1dB True Peak"
echo "========================================="
# Execute ffmpeg
# -c:v copy : Copies the video stream without re-encoding
# -af "loudnorm=I=-14:TP=-1.0" : Applies the loudnorm filter targeting -14 LUFS and -1.0dB True Peak
# -c:a aac -b:a 256k : Re-encodes the audio to AAC at a high quality (adjust bitrate if needed)
ffmpeg -i "$INPUT_FILE" -c:v copy -af "loudnorm=I=-14:TP=-1.0" -c:a aac -b:a 256k "$OUTPUT_FILE"
# Check if the command was successful
if [ $? -eq 0 ]; then
echo "========================================="
echo "Success! Normalized video saved as: $OUTPUT_FILE"
else
echo "========================================="
echo "Error: Something went wrong during processing."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment