24 September 2006

Normalising volume of mp3 tracks

(find /srv/files/music -type f -iname '*.mp3' -print0 | xargs -0 -n 1 mp3gain -r -k -d 2) | tee mp3gain.log

MP3Gain does not decode and re-encode the mp3 to change its volume (this is good). You can change the volume as many times as you want, and the mp3 will sound just as good (or just as bad!) as it did before you started. Mp3Gain uses a special algorithm to calculate how loud the file actually sounds to a human's ears and writes a tag corresponding to the decibel value in the mp3. That tag will be read by any mp3 player that you play the file with. Let Mp3Gain analyze your whole mp3 library and all your songs will sound the same volume! But if for some reason, you want the volume back to its original value, Mp3Gain can remove the tag for you and the volume will be just as before.

You can first remove any existing gain values for music retrieved from unknown source using:

find . -type f -iname '*.mp3' -print0 | xargs -0 mp3gain -u