Skip to content

mp3rgain: A drop-in Rust replacement for mp3gain with full command-line compatibility #38

@M-Igashi

Description

@M-Igashi

Hello!

I wanted to share a project that might be of interest to the mp3gain community.

Introducing mp3rgain

I've created mp3rgain, a drop-in replacement for mp3gain written in Rust. It aims for full command-line compatibility with the original mp3gain, so existing scripts and workflows continue to work without modification.

Command-line Compatibility

mp3rgain uses the same command-line syntax as mp3gain:

# These commands work identically in both tools
mp3gain -g 2 song.mp3       # original mp3gain
mp3rgain -g 2 song.mp3      # mp3rgain (drop-in replacement)

mp3gain -d 4.5 song.mp3     # apply dB
mp3rgain -d 4.5 song.mp3

mp3gain -s c song.mp3       # check/analyze
mp3rgain -s c song.mp3

Supported options: -g, -d, -s c, -p, -c, -q, -v, -h

Why a drop-in replacement?

The original mp3gain has been an invaluable tool for many years, but:

  • Development appears to have stalled
  • There are reports of compatibility issues with Windows 11
  • Building from source can be challenging on modern systems
  • Users need a tool that "just works" on modern platforms

Features

  • Full CLI compatibility - Same command-line interface as mp3gain
  • Lossless - Modifies global_gain field directly, no re-encoding
  • Cross-platform binaries - macOS, Linux, Windows (x86_64 and ARM64)
  • Zero dependencies - Single static binary, no external tools needed
  • Memory safe - Written in Rust

Technical Compatibility

mp3rgain uses the same approach as the original mp3gain:

  • Modifies the global_gain field in MP3 frame side information
  • Each gain step = 1.5 dB (per MP3 specification)
  • Supports MPEG 1/2/2.5 Layer III
  • Handles VBR and CBR files
  • Preserves ID3v2 tags

Current Status

Implemented:

  • -g <i> - Apply gain in steps
  • -d <n> - Apply gain in dB
  • -s c - Check/analyze files
  • -p - Preserve timestamp
  • -c - Ignore clipping warnings
  • -q - Quiet mode

Not yet implemented (contributions welcome!):

  • -r - Track gain (requires ReplayGain analysis)
  • -a - Album gain (requires ReplayGain analysis)
  • -u - Undo from APEv2 tags

Links

Looking for Contributors

I'm actively looking for contributors, especially those with experience in:

  • Windows development and testing (especially Windows 11)
  • ReplayGain implementation (-r and -a options)
  • APEv2 tag handling (-u option)
  • MP3 format internals

If anyone from the mp3gain community would like to contribute, test, or provide feedback, I would greatly appreciate it!

Installation

# Homebrew (macOS)
brew install M-Igashi/tap/mp3rgain

# Cargo (all platforms)
cargo install mp3rgain

# Or download binaries from GitHub Releases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions