I have been always using FooBar2000 to add ReplayGain tags to my music library (consisting of .mp3 or .ogg files). On my new computer I would like to avoid installing Wine for just this task.

Are there any native tools that I can use for the same purpose?

I don't mind if they are command-line only, or to use two different programs for mp3 and ogg, but I want to be absolutely certain that they only write a tag and do not mess with the original file otherwise, e.g. by actually reencoding at a different volume.

  • 1
    Since mp3gain is gone in recent versions of Debian/Ubuntu, at least from the official repositories, where it has been removed, python-rgain is a proper replacement. Its usage is just as simple: replaygain *.mp3 Unfortunately, this replacement is looking for a new maintainer as well, so hopefully it won't disappear as well.
    – caw
    Sep 15, 2017 at 21:41

6 Answers 6


There are command line tools for calculating ReplayGain values and adding ReplayGain tags. To install the tools for mp3, ogg and FLAC do the following:

sudo apt-get install mp3gain vorbisgain flac

Then to add ReplayGain tags to an album that consists of all files in a directory do the following for mp3:

mp3gain -a *.mp3

For the same task when the album is in ogg vorbis do the following:

vorbisgain -a *.ogg

For the same task when the album is in FLAC files do the following:

metaflac --add-replay-gain *.flac

If you want to add ReplayGain tags to files that are not albums instead use the -r option for mp3gain and vorbisgain (there is no corresponding option for metaflac):

mp3gain -r *.mp3
vorbisgain -r *.ogg

All tools can also be used to remove ReplayGain tags.

As always, make sure you have backups before proceed with any file modification. I have never had problems with these tools but I cannot guarantee they are failsafe (also, your computer could crash or you might have a power outage halfway through the process).

  • Thank you for the information, but I am a bit scared by mp3gain. According to wiki.hydrogenaudio.org/index.php?title=ReplayGain#MP3Gain and bobulous.org.uk/misc/Replay-Gain-in-Linux.html#mp3gain is seems that it can actually change the file itself, not only its tags. Is it really safe to use?
    – Andrea
    Feb 23, 2012 at 9:29
  • @Andrea I have used mp3gain for at least five years without any trouble. That does of course not rule out that such a problem exist but note that in those link it is indicated as very rare. I may want to study the -w option of mp3gain as indicated in hydrogenaudio.org/forums/lofiversion/index.php/t34154.html. Finally, you should always keep backups of important files such as media and, thus, if do not like the result of applying ReplayGain you can revert.
    – N.N.
    Feb 23, 2012 at 9:42
  • Uhm... I still have a doubt. Following your link, I see that the audio file is changed anyway. So I cannot just disable replaygain from the player and have the original file play without changes. I think Foobar just writes a metatag at the beginning, and then it is up to the player to increase the gain according to this tag. Am I missing something?
    – Andrea
    Feb 23, 2012 at 11:56
  • @Andrea As I have understood ReplayGain and mp3gain it is only active is its enabled in the player but I am no export. Perhaps you should ask a new question about this.
    – N.N.
    Feb 23, 2012 at 12:11
  • 1
    This does not work in ubuntu 18.04
    – Pedro Rolo
    Nov 8, 2019 at 12:46

Instead of being "a bit scared" or following unrelated links, why not simply read the manual?

From man mp3gain:

   mp3gain optionally writes gain adjustments directly into the encoded data.  In  this
   case,  the  adjustment works with all mp3 players, i.e. no support for a special tag
   is required.  This mode is activated by any of the options -r, -a, -g, or -l.

   If none of the above options are given, the recommended gain change is instead writ‐
   ten  to  a special tag in the mp3 file. In this case, the adjustment only works with
   mp3 players that support this tag.  Some mp3 players refer to  this  as  ReplayGain.
   The  tag is written either in APEv2 format (default) or in ID3v2 format (with -s i).
   If you only want to print the recommended gain change (and not modify  the  file  at
   all) you may use the -s s (skip tag) option.

So it only modifies the audio stream if you tell it to, otherwise it writes to tags only.

Side note: many of the URLs posted in comments are not related to current mp3gain found in Ubuntu: they are either terribly outdated or they refer to the windows version.

Whenever in doubt as how a given command works, always try man first. If that is not enough (or no man page available), use the correct upstream website, which can be checked in Ubuntu's package page.


I got part of the way through (okay most of the way through :( ) writing a wrapper script for the answer supplied by "N.N." when I discovered rgain. The answers recommending mp3gain wouldn't work for me as my library is mostly flac. rgain (listed in package repositories as python-rgain) is a library for interacting with replay gain tags of various file types, but it also comes with some wrapper scripts for it's most apparent uses. I'm currently running it, it seems like it will take a long time, and we shall see how it performs in time...

sudo apt-get install -y python-rgain
collectiongain ~/Music


Edit: I have been using it for some time now and while it's not perfect, it has been a huge improvement to listening to music. I'd say I have to adjust the volume maybe 10-15% as much as I used to. It did take three or four days on my crappy old computer to analyze my whole library. I'm about to start it on some new stuff I've downloaded.

Also, when I was running it the first time, it got interrupted a few times, and didn't explain why. I just ran it again, and it picked up analyzing where it left off, having successfully saved the tags it had done so far. What I mean is, it scans much faster than it analyzes so if it stops just restart it.

  • This is arguably not an answer to the question, since the question involved only MP3s and Oggs. You might want to move this into its own question (where it's acceptable to also answer the question). Dec 10, 2017 at 3:17
  • 1
    Well, it doesn't only answer this question. It does answer this question, but it also answers some more. The package I suggested handles MP3s, Oggs, FLACs, and others. My library contains mp3s and oggs as well, I just needed a more complete solution, and this one is easier by far than all the others suggested. And less risky, as it definitely doesn't use the mp3gain feature that is lossy, unless you specifically tell it to. Dec 13, 2017 at 14:41
  • Ahh, fair enough. Dec 14, 2017 at 0:24

UPDATE: mp3gain should not alter your audio stream unless you use one of the -r, -a, -g, or -l options. On my (vanilla) Ubuntu 12.04 installation it appeared to do so at first, but now I am unable to reproduce that. I might have been tricked by Audacity into thinking the audio stream changed when comparing my before/after files, e.g. by an Audacity plug-in applying replaygain tags as an input gain stage before opening mp3-files in its mixer.

If you're in doubt about whether your audio streams change, you may want to compare them by doing as follows:

  1. Make a copy of a not-yet-tagged mp3 file
  2. Use mp3gain on one of the copies
  3. Line up both versions of the file in a DAW (such as Audacity, Cubase, Garageband, ProTools, Audition, or equivalent). Make sure they're sample-accurately lined up, and that no other application is playing audio on your computer
  4. Flip the phase on one of the copies (a.k.a. "invert phase", etc) and play back the mix
  5. If you cannot hear sound, the audio streams are 100% identical, and thus unaffected by mp3-/vorbisgain. If you hear something, they're different.
  • +1 for the suggestion on how to check whether the audio stream has changed
    – Andrea
    Apr 13, 2012 at 15:54
  • 1
    -1: wrong. mp3gain only changes the audio stream if -r, -a, -g, or -l. options are used.
    – MestreLion
    Nov 22, 2012 at 13:21

I just wanted to add a little more information. I will reinforce that mp3gain will only modify the file if you tell it to; otherwise it will merely add a tag. Also, SoundKonverter will provide a GUI interface to mp3gain and several other tools to calculate gain for other files. There is an option in SoundKonverter to modify the file, but it is off by default, only adding a tag.

One other point that I wanted to make clear is that even if you modify the file directly with mp3gain, it does not re-encode the file. One of the features of the mp3 format is the ability to change the gain (or "volume") of a file nondestructively, i.e. without re-encoding.

  • To install mp3gain on Ubuntu, simply do sudo apt install mp3gain. Jan 11, 2023 at 2:00

An old question, but still a question one can have.

Not mentioned here is "Quod Libet" - Music player and music library manager. It has a plugin for replaygain that just has to be enabled. Then it's possible to have tracks analyzed and tagged with replaygain information (REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK, REPLAYGAIN_ALBUM_GAIN, REPLAYGAIN_ALBUM_PEAK)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .