GitHub

mp3rgain vs mp3gain, aacgain, rsgain & ffmpeg

Nearly every tool here is a ReplayGain tool — they all measure loudness the same way in principle. What actually separates them is where the correction ends up: in a tag the player reads, in the bitstream itself, or in re-encoded samples. This page starts there, then places each tool — including mp3rgain — on the resulting map.

One measurement, three destinations

  1. Write ReplayGain tags. Measure loudness, store the result as metadata, and let the player apply it. Nothing about the audio changes. rsgain, loudgain, foobar2000 and ffmpeg -af replaygain all do this.
  2. Re-encode the audio. Decode, apply gain to the samples, encode again. Works everywhere, at the cost of a generation of lossy quality on every pass. ffmpeg loudnorm is the usual example.
  3. Rewrite the gain field inside the bitstream. MP3 and AAC frames carry a global_gain value that scales decoder output. Change it and the volume changes permanently, for every player, without decoding a single sample. mp3gain, aacgain, foobar2000 and mp3rgain do this.

1 and 3 are not rival camps. mp3gain, aacgain and mp3rgain do both: they run a ReplayGain analysis, bake the result into the bitstream, and write standard REPLAYGAIN_TRACK_GAIN / REPLAYGAIN_ALBUM_GAIN tags describing the residual, so a ReplayGain-aware player and a dumb one arrive at the same loudness. foobar2000 covers both routes too. "Tagger versus gain tool" is the wrong axis — the real question is whether a tool can touch the bitstream at all, and whether it can put it back.

Which destination do you want? If every device you use honours ReplayGain tags, stop at approach 1 — it is reversible by definition and stores track and album values side by side. If some of them do not — car stereos, older hardware players, DJ gear, cheap DAPs, many phone apps — the tags are silently ignored and approach 3 is the only lossless answer.

Where each tool sits

ToolStatusReplayGainGain applied byFormatsUndoPlatform
mp3rgainActiveRG1 default, --rg2 / --r128 opt-in — writes tagsBitstream gain fieldMP3, AAC/M4AYesmacOS, Linux, Windows (CLI + GUI)
mp3gainUnmaintained (~2015)RG1 only — writes tagsBitstream gain fieldMP3YesWindows, Linux (aging builds)
aacgainUnmaintained (~2009)RG1 only — writes tagsBitstream gain fieldMP3, AAC/M4AYesRarely builds on modern 64-bit systems
foobar2000ActiveRG2 / R128 — the reference implementationTags, or bitstream gain fieldTags for most formats; bitstream for MP3 and AAC in MP4/MKATags yes — baked-in gain noWindows GUI only
rsgainActiveRG2 / R128 — writes tagsPlayer, from the tagsManyN/A — tags onlyCross-platform CLI
loudgainSuperseded by rsgainRG2 / R128 — writes tagsPlayer, from the tagsManyN/A — tags onlyLinux, macOS
ffmpeg loudnormActiveNo — R128 normalizer, not a taggerRe-encoded samplesEverythingNo — lossyCross-platform CLI

Two rows deserve a footnote. foobar2000 is not just another entry here: the Hydrogenaudio community around it is where the ReplayGain 2.0 specification was worked out, and its scanner is the practical reference other implementations get checked against. If you want textbook-correct ReplayGain and you are on Windows, that is the answer, and mp3rgain's --rg2 mode exists to agree with it rather than to compete with it. And the three bitstream tools at the top are also taggers — the classic mp3gain lineage has always written ReplayGain tags next to the gain it bakes in.

Why the classic tools ran out

What went unmaintained was never ReplayGain itself — foobar2000 and rsgain carry the standard forward in better shape than ever. What lapsed was the specific lineage that pairs a ReplayGain analysis with a lossless bitstream rewrite on the command line. mp3gain's upstream development stopped around 2015 and aacgain's around 2009. aacgain is the harder loss: it is the tool people reach for when a library contains M4A files, and it has become difficult to build on current 64-bit toolchains. That left two practical options for lossless AAC gain: run an ancient binary, or sit at a Windows desktop with foobar2000 — which does the job well, but only from the GUI and without an undo path.

mp3rgain exists to cover the case neither one does: one memory-safe Rust binary for both MP3 and AAC, scriptable and headless, with undo on both — which is what makes it usable in a container or a cron job where a mistake needs to be reversible. If you are at a Windows desktop, foobar2000 remains an excellent answer.

Reference levels

A recurring source of confusion when comparing tools is that they normalise to different targets, so identical inputs legitimately produce different numbers:

StandardReferenceMeasured bymp3rgain flag
ReplayGain 1.089 dBmp3gain, aacgain, mp3rgain (default)default
ReplayGain 2.0−18 LUFSfoobar2000 (reference), rsgain, loudgain--rg2
EBU R128−23 LUFSffmpeg ebur128, broadcast tooling--r128

mp3rgain defaults to ReplayGain 1.0 so re-scanning an mp3gain-processed library reproduces the same values instead of shifting everything. --rg2 and --r128 switch to ITU-R BS.1770 gated measurement when you would rather match the modern taggers — the target being foobar2000's numbers, not a separate dialect of them. In those modes mp3rgain also writes a REPLAYGAIN_ALGORITHM tag, so a library scanned in mixed modes stays legible.

Migrating from mp3gain or aacgain

The CLI flags, the TSV output layout, and the APEv2 mp3gain_undo tag are all mp3gain-compatible. For most setups migration is a single substitution:

sed -i 's/\bmp3gain\b/mp3rgain/g' your_script.sh

Existing undo tags written by mp3gain remain valid, so a library that mp3gain already processed can be rolled back with mp3rgain -u. The full flag-equivalence table, Dockerfile substitution patterns and the intentional behavioural differences are documented in the migration guide, and the bit-level verification against the original mp3gain is in the compatibility report.

When not to use mp3rgain

An honest boundary is more useful than a feature list:

Next