Skip to content
A script for adding replaygain tags the way I like them
Python Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

README.mkdn Add Replay Gain tags to your whole music library

To use this script, simply run it on your Music library directory. The help text ( --help) contains (almost) all you need to know:

usage: [-h] [-f] [-i] [-n] [-g auto] [-j 2] [-q] [-v]
                     [music_directories [music_directories ...]]

Add replaygain tags to your music files.

positional arguments: music_directories Directories in which to search for music files.

optional arguments: -h, --help show this help message and exit -f, --force-reanalyze, --force_reanalyze Reanalyze all files and recalculate replaygain values, even if the files already have valid replaygain tags. Normally, only files without replaygain tags will be analyzed. -i, --include-hidden, --include_hidden Do not skip hidden files and directories. -n, --dry-run, --dry_run Don't modify any files. Only analyze and report gain. -g auto, --gain-type auto, --gain_type auto Can be "album", "track", or "auto". If "track", only track gain values will be calculated, and album gain values will be erased. if "album", both track and album gain values will be calculated. If "auto", then "album" mode will be used except in directories that contain a file called "TRACKGAIN" or ".TRACKGAIN". In these directories, "track" mode will be used. The default setting is "auto". -j 2, --jobs 2 Number of albums to analyze in parallel. The default is the number of cores detected on your system. -q, --quiet Do not print informational messages. -v, --verbose Print debug messages that are probably only useful if something is going wrong.

Note that you need the 'rgain' python module installed, with the accompanying replaygain script in your $PATH. (This script doesn't currently import the rgain module despite both being python, since it was easier to implement by having it call the script instead. Patches fixing this are welcome.)

What is an album?

When doing "album" or "audiophile" Replay Gain tags, one needs to carefully define an album. For example, if you happen to have half an album in FLAC format and the other half in MP3, they might be at different volumes to begin with, so calculating Replay Gain tags on the whole album is a bad thing -- the MP3s will end up too loud and the FLACs too quiet, or vice versa.

Anyway, this script considers two tracks to belong to the same "track set" for the purposes of calculating audiophile gain if:

  • They have the same album name tag
  • They have the same disc number tag (or lack thereof)
  • They are in the same directory on the filesystem
  • They are both the same music format (MP3, OGG, FLAC, etc.)

I may add "same album artist" to this list in the future

See also

Transfercoder, a tool for transferring your music to your portable mp3 player while simultaneously transcoding music formats that the player doesn't recognize.

Something went wrong with that request. Please try again.