Skip to content

replaygain: add metaflac backend#6800

Open
SamadBallaj1 wants to merge 1 commit into
beetbox:masterfrom
SamadBallaj1:fix-issue-1203
Open

replaygain: add metaflac backend#6800
SamadBallaj1 wants to merge 1 commit into
beetbox:masterfrom
SamadBallaj1:fix-issue-1203

Conversation

@SamadBallaj1

@SamadBallaj1 SamadBallaj1 commented Jun 28, 2026

Copy link
Copy Markdown

The replaygain plugin can't compute ReplayGain when metaflac is the only tool available. The existing backends (command, gstreamer, audiotools, ffmpeg) each need something heavier installed, which doesn't work on minimal setups like a NAS where those won't install. Issue #1203 asks for a metaflac based option so FLAC users on those setups can still tag ReplayGain.

This adds a metaflac backend for that case. It runs metaflac --add-replay-gain to compute the gain and reads the values back with metaflac --show-tag. I modeled it on the existing CommandBackend since both wrap an external tool. It only handles FLAC, skips other formats, and shifts the gain to the configured targetlevel like the other backends.

One limitation: metaflac scans a whole album in one pass, so the files of an album need the same sample rate and channel layout.

Before, selecting the metaflac backend failed:

$ beet replaygain
UserError: Selected ReplayGain backend metaflac is not supported.

After, the backend works and the plugin tests pass:

$ python -m pytest test/plugins/test_replaygain.py
7 passed, 4 skipped

The 4 skipped are the Opus R128 cases, which don't apply to the metaflac path.

To Do

  • Documentation.
  • Changelog.
  • Tests.

@SamadBallaj1 SamadBallaj1 requested a review from a team as a code owner June 28, 2026 23:25
@github-actions github-actions Bot added the replaygain replaygain plugin label Jun 28, 2026
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.08772% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.67%. Comparing base (08081f3) to head (345b72f).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/replaygain.py 35.08% 36 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6800      +/-   ##
==========================================
- Coverage   74.97%   74.67%   -0.30%     
==========================================
  Files         163      163              
  Lines       20957    21014      +57     
  Branches     3302     3308       +6     
==========================================
- Hits        15712    15693      -19     
- Misses       4485     4563      +78     
+ Partials      760      758       -2     
Files with missing lines Coverage Δ
beetsplug/replaygain.py 27.01% <35.08%> (+0.68%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@SamadBallaj1 SamadBallaj1 force-pushed the fix-issue-1203 branch 2 times, most recently from 77f8ddb to 5b41a28 Compare June 28, 2026 23:49
Add a MetaflacBackend that computes ReplayGain for FLAC files with metaflac --add-replay-gain and reads the values back with --show-tag. Only FLAC is supported. Includes docs, a changelog entry, and tests.
@SamadBallaj1

Copy link
Copy Markdown
Author

Pushed some updates, this is ready for review whenever you have a chance. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

replaygain replaygain plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant