Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Find average volume change needed for album

x=0 ; for word in *.mp3 ; do x=$((x+1)) ; ffmpeg -i "${word}" -af "volumedetect" -vn -sn -dn -f null /dev/null 2>&1 | awk "BEGIN{OFS=\",\"} /mean_volume/{a=\$5} /max_volume/{b=\$5} END{print a,b}" | sed -r -e "s/^/${x},/;" ; done

And then I saw the whole list of max and mean volumes. So my minimum max_volume is -8.3, so I need to add this amount to each file. I think ffmpeg does not use fractional decibels, so I chose 9.

x=0 ; time for word in *.mp3 ; do x=$((x+1)) ; new="new${word}" ; ffmpeg -i "${word}" -af "volume=9dB" "${new}" ; done

Comments