Visitor comments: Comments about Replay Gain in Linux

Go to the page to which these comments refer.

Showing comments 1–5 (of 5).

More ways to replaygain

I've written a script to automate adding replaygain tags to an entire music library. You can find it here:

Also, Quod Libet doesn't just support using replaygain tags. It also has an excellent plugin for *adding* them for all file types that it can play.

Posted 22nd September 2010 @ 15:37:33 UTC by Ryan

mp3gain 1.5.2+ can also write ID3v2 tags

Newer versions of mp3gain can now also write id3v2 tags: they add the standard RVA2 tags, as well as mp3gain-specific MP3GAIN_ALBUM_MINMAX, MP3GAIN_MINMAX and MP3GAIN_UNDO. The command line option is "-s i".

Note that mp3gain changes more than just tags! It also adjusts the bulk volume level for each MP3 frame (a field in each frame's header). That is a lossless operation because the audio stream is not re-encoded. But you absolutely need the MP3GAIN_UNDO tag if you would like to revert that change.

Posted 19th October 2010 @ 22:29:58 UTC by Hans from Colorado

I made some changes to also incorporate mp3 and vorbis scanning, and to do it as quietly as possible so it can be run via cron.


# Script created by Bobulous, October 2008.
# See
# Modified by Qsx/4011 to also tag mp3 and vorbis files
# This script takes as an argument a directory name,
# then uses metaflac to add Replay Gain tags (for album and
# track gain) to each FLAC, MP3, or Vorbis file in that directory.
# Use find (with -exec) to call this script on
# a directory structure containing FLAC files, so that this
# script is run on each directory in that structure. E.g.
# find ./music/flac -type d -exec ~/ '{}' \;
# Or, better yet, try GNU Parallel to use multiple CPU cores
# See

# Error codes

# Check that the argument passed to this script is a directory.
# If it's not, then exit with an error code.
if [ ! -d "$1" ]
	echo "Arg "$1" is NOT a directory!"

# Count the number of audio files in this directory.
flacnum=`ls "$1" | grep -c \\.flac`
mp3num=`ls "$1" | grep -c \\.mp3`
vorbisnum=`ls "$1" | grep -c \\.ogg`

# If no audio files are found in this directory,
# then exit without error.
test $flacnum -lt 1 && test $mp3num -lt 1 && test $vorbisnum -lt 1 && exit 0

# Run metaflac on the FLAC files in this directory.
test $flacnum -gt 0 && metaflac --add-replay-gain "$1"/*.flac

# Run mp3gain on the MP3 files in this directory.
test $mp3num -gt 0 && mp3gain -q -s i "$1"/*.mp3

# Run vorbisgain on the Vorbis files in this directory.
test $vorbisnum -gt 0 && vorbisgain -afqn "$1"/*.ogg

exit 0

Posted 28th January 2012 @ 19:52:31 UTC by Qsx/4011 from Bellport, New York


I discovered rgain, written in python, which is great!

Posted 15th February 2015 @ 11:44:55 UTC by arnaud

(untitled comment)

Hi, thanks for the article!

I have a suggestion though, both scripts can be replaced with this simple function:

Just stick it in your .bashrc, or .zshrc, or .whateverrc, and call it like this:
$ replaygain ~/Music

It'll work for both FLAC and MP3 records, setting the ReplayGain in album mode, just like your script.

Posted 5th July 2017 @ 16:31:06 UTC by jebus

Cache was empty or disabled.