GitHub
v3.12.1 · MIT License · Rust

Lossless MP3/AAC
Volume Normalizer

A modern mp3gain / aacgain replacement written in Rust. mp3rgain adjusts volume by rewriting the global_gain field in each frame: no re-encoding, no quality loss, and -u undoes it. As far as we know, the only actively maintained CLI for lossless AAC/M4A bitstream gain.

BEFORE · QUIET → AFTER · +6.0 dB · LOSSLESS

DJ prepping tracks for rekordbox and CDJs? Bake'n Deck is built on the same engine. More below ↓

The tools everyone used have stalled

For two decades, mp3gain and aacgain were the way to run a ReplayGain scan and make the result permanent: tags written, gain baked in, quality untouched. Neither has shipped a release in years.

  • mp3gain: no release since 1.6.2, whose release and Windows binaries are unpatched
  • aacgain: last release 2.0.0 (2019), last commit 2022, no security fixes
  • rsgain and loudgain stop at ReplayGain tags, which car stereos, hardware players and many apps ignore
  • Re-encoding (e.g. ffmpeg loudnorm) fixes volume but costs quality on every pass
  • foobar2000 is alive and is the reference-grade ReplayGain suite, but it is a Windows GUI and its baked-in gain has no undo

Full comparison: mp3rgain vs mp3gain, aacgain, rsgain and ffmpeg →

ReplayGain tags vs baked-in gain
Analyze loudness (ReplayGain 1.0 / BS.1770)
↓
Stop at tags → many players ignore them
↓
mp3rgain: rewrite global_gain in the bitstream and write the tags
→ correct volume on every player, losslessly

Bake the gain into the file, reversibly

MP3 and AAC frames carry a global_gain field that scales decoder output. mp3rgain rewrites it in every frame (1 step = 1.5 dB), writes ReplayGain tags and an undo tag, and never touches the compressed audio data. Flags, TSV output and undo tags follow mp3gain, so most scripts and beets configs keep working.

mp3rgain: album gain
$ mp3rgain -a *.mp3 mp3rgain Analyzing album gain for 3 file(s) Target: 89 dB (ReplayGain 1.0) ... Album gain: -3.0 dB (-2 steps) Album peak: 0.7289 v 01-intro.mp3 (308 frames, -3.0 dB) v 02-title.mp3 (308 frames, -3.0 dB) v 03-outro.mp3 (308 frames, -3.0 dB) $ mp3rgain -u 01-intro.mp3 mp3rgain Undoing gain changes on 1 file(s) v 01-intro.mp3 (308 frames restored)

Features

Everything the classic tools did, plus the parts they never got to.

🔊

Truly lossless

Gain changes go through the global_gain field; the compressed audio data is never decoded or re-encoded. Works for MP3 and AAC: in M4A/MP4, in the audio track of a video MP4, and as a raw ADTS .aac stream.

↩️

Undoable

Every gain change is recorded in an undo tag (mp3gain's own on MP3). mp3rgain -u puts every frame back to its original gain, on AAC too.

🔁

Drop-in mp3gain replacement

mp3gain's flags, TSV output and APEv2 undo tags. Most scripts, Dockerfiles and beets configs keep working after a one-line sed; the few differences are documented.

🎚️

RG 2.0 & EBU R128

ReplayGain 1.0 by default, landing on the same gain steps as mp3gain. Opt-in --rg2 / --r128 switch to BS.1770 gated loudness (−18 / −23 LUFS), consistent with rsgain and ffmpeg.

📦

No external tools

One binary. No ffmpeg, mp3gain or aacgain needed. Decoding uses the pure-Rust Symphonia library, and mp3rgain's own code has no unsafe blocks.

⚡

Parallel by default

Files are analysed and written on all CPU cores. Tune with -j, or use -j 1 for a serial run.

🖥️

Desktop GUI included

mp3rgui: a drag-and-drop app for macOS, Windows and Linux, built on the same processing code as the CLI.

🐳

2 MB Docker image

Multi-arch (amd64/arm64) FROM scratch image on GHCR, for containerized batch jobs such as Plex library maintenance.

🦀

Rust library crate

Embed lossless gain in your own tools with the mp3rgain crate. It powers Bake'n Deck's DJ loudness pipeline.

🌍

Cross-platform

macOS, Linux and Windows, on x86_64 and ARM64. Available through Homebrew, MacPorts, winget, AUR, an apt repository for Debian and Ubuntu, Nix, pkgx, Termux, Docker and crates.io.

For DJs: Bake'n Deck

CDJs and other DJ hardware ignore ReplayGain tags, and rekordbox Auto Gain never makes it onto the USB stick. Bake'n Deck is a rekordbox → CDJ prep toolkit by the same author, with mp3rgain built in as its MP3/AAC engine. It writes your prep into the files themselves.

🎚️

Headroom

Gain only, no limiter. Raises or lowers each track to a −0.5 dBTP true peak ceiling: MP3 and AAC in lossless 1.5 dB steps via mp3rgain, FLAC, AIFF, WAV and ALAC with exact gain. Cues and beatgrids stay linked.

🔀

Sort

Orders every playlist by Alphanumeric key, then BPM, inside your exported rekordbox XML, so the CDJ plays it in exactly that order.

💾

CDJ Safe

Transcodes a playlist to 320 kbps CBR MP3 with cues and beatgrid carried over: the backup USB for CDJs that only play MP3 reliably.

Free MIT-licensed CLI for macOS, Windows and Linux (brew install M-Igashi/tap/baken · winget install M-Igashi.baken), plus a native Mac app on the Mac App Store · 日本語

Install

CLI: mp3rgain

Scriptable, headless, CI-friendly
macOS (Homebrew)brew install M-Igashi/tap/mp3rgain
macOS (MacPorts)sudo port install mp3rgain
Windows (winget)winget install M-Igashi.mp3rgain
Arch Linux (AUR, third-party)yay -S mp3rgain-bin
Debian / Ubuntu (apt repo)sudo apt install mp3rgain
Nix / NixOSnix profile install github:M-Igashi/mp3rgain
pkgx (macOS / Linux)pkgx mp3rgain
Android (Termux, TUR)pkg install tur-repo && pkg install mp3rgain
Docker (GHCR)docker pull ghcr.io/m-igashi/mp3rgain:latest
Cargocargo install mp3rgain

GUI: mp3rgui

Drag-and-drop desktop app
macOS (Homebrew)brew install --cask M-Igashi/tap/mp3rgui
Windows (winget)winget install M-Igashi.mp3rgui
Arch Linux (AUR)yay -S mp3rgui
Debian / Ubuntu (apt repo)sudo apt install mp3rgui

Uninstall commands, checksum verification and troubleshooting are on the full install guide · every flag is documented in the CLI reference · pre-built binaries on GitHub Releases.

The GUI: mp3rgui

Same lossless processing, no terminal required. Drop in files or folders, analyze, apply, undo.

mp3rgui showing track and album ReplayGain analysis for a batch of files

Download Stats

Download counts from GitHub Releases (which Homebrew and winget install from), crates.io, AUR, the Ubuntu PPA and GHCR are collected daily on a public dashboard.

View Download Statistics