#!/usr/bin/env bash # Use this to normalize the volume of a video or audio file using the average loudness, or RMS-based normalization. It does a pretty good job! # If you want to modify the volume manually then checkout the analyze-volume and change-volume scripts. # # This does not re-encode video when given a video file. # # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" YELLOW="$(tput setaf 3)" BLUE="$(tput setaf 4)" MAGENTA="$(tput setaf 5)" CYAN="$(tput setaf 6)" BOLD="$(tput bold)" NORMAL="$(tput sgr0)" else RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" BOLD="" NORMAL="" fi if [[ $1 == "" ]]; then printf "${BOLD}${RED}Usage: normalize-volume