Repository navigation
convert: write R128 gain tags to Opus files - #7127
Open
berettavexee wants to merge 1 commit into
Open
berettavexee wants to merge 1 commit into
berettavexee wants to merge 1 commit into
Conversation
Opus players only honour R128_* gain tags, but transcoded copies only received the library's REPLAYGAIN_* values, and none at all when the copy was made at import time, before replaygain ran. Derive R128 track and album gains from the library's ReplayGain values when writing Opus files. When the library has no gain data, compute the track gain on the converted file with the replaygain plugin, if enabled. Also update the gain tags of destination files that already exist, so running convert again fills in previously converted files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7127 +/- ##
==========================================
- Coverage 80.63% 80.62% -0.02%
==========================================
Files 149 149
Lines 21254 21299 +45
Branches 3284 3292 +8
==========================================
+ Hits 17139 17172 +33
- Misses 3288 3297 +9
- Partials 827 830 +3
🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
converttranscodes to Opus, the resulting files end up with no usablegain information:
R128_TRACK_GAIN/R128_ALBUM_GAIN(RFC 7845),while a library of e.g. FLAC files only stores ReplayGain values
(
rg_*), whichwrite_metadatacopies asREPLAYGAIN_*tags.auto_keep, the copy is made in an early import stage, i.e. beforethe
replaygainplugin has analysed the imported items, so it gets no gaintags at all.
beet replaygainonly processes library items, and converted copies arenot in the library, so there is no way to fix them afterwards. Re-running
beet convertskips them since the destination already exists.This PR makes
converttake care of the gain tags of the Opus files itwrites:
r128_*gains areused as is, otherwise
rg_*gains are shifted by -5 dB (ReplayGain 2.0references -18 LUFS, R128 -23 LUFS).
is computed on the converted file using the
replaygainplugin's backend,when that plugin is enabled. The library item is not modified.
still updated (without re-encoding). Tags that are already up to date are
not rewritten, so running
convertagain stays cheap. This lets users fixpreviously converted files with
beet convert.Linked/hardlinked files are left alone, since they are the library files
themselves and are handled by
replaygaindirectly.AI disclosure: I used Claude Code to write the patch,the tests.
I reviewed the change, ran the tests. I am one of the three one been that
care about Ogg Opus ;-)