-
Notifications
You must be signed in to change notification settings - Fork 184
Replaygain scanner should store R128_TRACK_GAIN in opus files and not REPLAYGAIN_TRACK_GAIN #1345
Comments
Can you checkout git/master (for 2.3.3). I've changed the tag reading/writing to use R128_TRACK_GAIN and R128_ALBUM_GAIN for Opus files. NOTE: any previous REPLAYGAIN_TRACK/ALBUM_GAIN tags are not removed. Does this resolve the issue? |
I will start up my Arch distro and compile it. |
I compiled Arch's AUR package cantata-git and the difference is still there. Opus files play louder than FLAC which is the opposite of some other players that play opus lower than FLAC. deadbeef-git works "like it should" and maybe Alex the developer can exchange some ideas? |
a) Have you confirmed with a tag editor that the correct tags have been written? i.e. jsut to confirm that Cantata is working, and the tags are there. |
a) Ican not see if the r128_track_gain tag is added using any of the players/taggers (Cantata, EasyTAG, Deadbeef and VLC). If I had wine installed on this machine I would be able to run Foobar2000 which probably would show it. b) Scanning using Cantata seem to add replaygain tags to both opus and FLAC files. They play the same volume in Deadbeef and VLC but not in Cantata itself even though that program was used to scan the files. When I open up the files i Deadbeef I can see that they both have REPLAYGAIN_ALBUMGAIN and REPLAYGAIN_TRACKGAIN. If I scan the opus and the FLAC file in Deadbeef they both get the mentioned tags and play at the same volume in Deadbeef and VLC but again not in Cantata. c) I found beetbox/beets#2557 which mentions that MPD uses r128 and probably not replaygain for opus if I understood it correctly. |
a) Please use kid3-qt - this shows all tags. If you have correctly scanned an opus file, then the tags will be R128_TRACK_GAIN and R128_ALBUM_GAIN. I have just tested this with a single opus file, and these tags were present. So, I know this is working. If you do not have these tags - then you are running the wrong Cantata version (are you sure you installed it?) b) Cantata does not play files. MPD plays the files. ALL Cantata is doing is processing and tagging the replay gain values. Please use a decent tag editor to remove all REPLAYGAIN and R128 tags (as stated Cantata will not remove existing tags). This will then reset the file to a default setting. Then re-scan with a newly built and installed Cantata. Confirm with kid3-qt that R128_TRACK_GAIN and R128_ALBUM_GAIN are in the list of tags. (REPLAYGAIN_TRACK_PEAK and REPLAY_GAIN_ALBUM_PEAK will also be present, as these are calculated, but I don't think these are used). Then play the file with MPD and with deadbeef. Are the levels now correct? ps. I've updated the issue title to be consistent with how I see this issue. And if correct, then Cantata now writes the correct tag name. |
Any updates? Have you had a chance to try the above? |
I created a FLAC and encoded it with opusenc. I then removed all tags from the files with kid3 except the artist and track tag so that cantata would show them. I scanned the two files with cantata they got the same replaygain tags but the opus file also recieved the r128 track and album tags which kid3 confirmed. The opus file does play louder (I guess 3dB louder) than the FLAC. In Deadbeef they also play at different volumes. What caught my attention though is that both replaygain and r128gain have -13.89 values. If I am correct r128 has a lower reference loudness and the tag should have maybe -16.89 or bigger than the replaygain tag. |
In Deadbeef the opus file has the following tag values: These tags are not visible in kid3. |
If I scan the files in Deadbeef then the files play back at the same volume in Deadbeef but not in Cantata. |
So, just to be clear - the opus file that Cantata scanned, this should only have; R128_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK, R128_ALBUM_GAIN, and REPLAYGAIN_ALBUM_PEAK. It should not have REPLAYGAIN_TRACK_GAIN and REPLAYGAIN_ALBUM_GAIN. Looking at the code, there is no way Cantata could have added R128_TRACK_GAIN and REPLAYGAIN_TRACK_GAIN So, I am confused when you state:
This is not possible just using Cantata. With a fresh file, just scanned by Cantata, it is not possible. All that I have changes is the tag name that the replaygain _GAIN tags are stored under. The calculation has not, and will not, be changed - it uses libebur128, and always has done. Again, Cantata does not playback files - MPD does.
Should deadbeef not be writing REPLAYGAIN_TRACK_GAIN? Not REPLAYGAIN_TRACKGAIN??? MPD (which is doing the playback), only reads R128_TRACK_GAIN (AFAIK) for opus. If deadbeef writes |
The problem is then that MPD only reads the r128 tags in opus files which leads to music files following different loudness standards. |
I did the same thing again but with another file and another computer (Solus) that doesn't have the git version. Cantana added the following tags (kid3 information): OPUS FLAC No R128_TRACK_GAIN was added the OPUS file. Using Deadbeef 0.7.2 tagger I saw no R128_TRACK GAIN either. Why it shows no R128_TRACK_GAIN might be because the OPUS support in 0.7.2 is, if I am correct, not as good as in the git/master. When I say Cantata plays I know it is MPD that plays in but I play it from inside of Cantata. |
I think we need to clarify a few things.
Is it safe to assume that you thunk deadbeef produces the correct replaygain values? For both FLAC and Opus? I've never used deadbeef (will try later), but I can see some subtle differences in its replygain scanning code that I could adapt. e.g. It uses a different 'reference' level. However, there is no specific opus scanning code - it would be the same for all codecs. Can you try the following:
In this thread https://hydrogenaud.io/index.php/topic,104878.0.html one poster thinks R128_XXX should be REPLAYGAIN_XXX - 5 ... this is all getting a bit messy... |
deadbeef.flac: deadbeef.opus: cantata.flac: cantata.opus: |
When using Deadbeef to view the tags the result is the following: deadbeef.opus: cantata.flac: cantata.opus: In Cantata/MPD, cantata.flac and cantata.opus does not play equally loud. The same goes for deadbeef.flac and deadbeef.opus. However, in Deadbeef the files deadbeef.flac and deadbeef.opus do play equally loud but cantata.flac and cantata.opus does not. |
That's interesting, thanks. Odd that The Cantata opus is both 0 - that's definitely an error. Can you upload the opus files (assuming they are non-copyright files) somewhere, so that I can download and test? Can I just confirm...
Does kid3 really show |
Yes, I noticed that too that one adds "dB" and one not. One interesting thing also is that when use Deadbeef's tag editor I can see that the cantata.opus also has a OPUS_HEADER_GAIN = 5.00 dB that the Deadbeef replaygain scan file does not. |
https://ufile.io/96rf3 |
OK, but I wont be able to access that file until 5pm BST at the earliest (which is about 5hours from now). As to [edit] In fact, you do have them mixed up. Cantata does append the |
I haven't said that Cantata does not add |
Deadbeef (git) might be buggy because now the deadbeef.opus file also has a |
Cantata does not add You seem to be mixing files up, which is causing a lot of confusion with this issue. |
I am not mixing up the files. I have double checked them. I am only reporting the tags the different tag editors report. If the Cantata does not write that tag and Deadbeef still show it then I don't know why that is the case. |
Wait - so its deadbeef showing it? That's different, I only care what a tag editor shows. Hence why asking you to use kid3 (or another, no preference on my end). I think deadbeef is showing you the settings it will use, and the default for this (guessing) is When I'm asking for values, these need to come from a tag editor - which will show you the only parts that I care about. i.e. I care what is set in the actual file, not what some (good or otherwise) player thinks that values should be. Now, its possible that I see you have edited your posts above, which makes things clearer - thanks :-) Is it correct to assume you now have:
If so, and
Do they now play at the same volume? |
Deadbeef is both a player and a tag editor. I will stop using it in this search for a solution if it makes it more difficult. |
If I use kid3 that you prefer I only get:
|
Players and files that play with equal loudness:
Players and files that play without equal loudness:
I wonder why opus developers opted for r128 and made it so difficult to apply popular replaygain. It is starting to drive me crazy and I might soon give up on opus just because of this issue that is important to me. |
...as asked, what about using a tag-editor to set |
When I added |
I edited my post where I posted the tags that Deadbeef shows. This post is after the kid3 results. There are so many numbers and tags that I messed up that one. It is also strange that Deadbeef calls tags REPLAYGAIN which kid3 called R128. |
The replaygain scanning code is based upon https://github.com/jiixyj/loudness-scanner Looking at this, it seems to handle the opus case. Also, R128_TRACK_GAIN, etc, need to be an integer number - so is a different format to REPLAY_TRACK_GAIN. I'll try to port the modifications to Cantata. I think the reason you see REPLAYGAIN with deedbeaf is that it tries to hide the differences shown in the UI. In the file, I think the R128 tags, etc, are used. |
OK, I think I understand things better now.
Some scanners, and the loudness-scanner above, modify OPUS_HEADER_GAIN. It appears as if this always affects decoding the file. If I had Cantata set this, then running the replaygain scanner again would result in lower values - as (I assume) the raw packets are modfied when ffmpeg loads them. I've updated Cantata's code to (I think) correctly set R128_XXX, but not adjusting OPUS_HEADER_GAIN Can you please checkout git/master and see if this is better? Please use new opus files, i.e. ones that have not had any replaygain scanning performed - just so that OPUS_HEADER_GAIN has not been adjusted by anything. |
The volume of the scanned cantata.opus is now closer to cantata.flac when being played back by Cantata/MPD. I am guessing the issue can be with MPD (too) because the deadbeef.* files that are played at the same volume in Deadbeef does not do so in Cantata. |
The cantata.opus scanned with Cantata now has (according to kid3):
|
Yup, those values look OK. As stated, the values are integers. The actual value is -2181/256 = -8.52dB You say the volume is closer. How close? Almost the same, just slightly better? If you play the flac and opus with MPD with MPDs replaygain disabled, is it the same difference then? |
Oh, thank you for that integer information. I had no idea. The cantata.* files play at the same volume if I turn off replaygain. It doesn't matter if replaygain is enabled or disabled it plays cantata.opus at the exact same loudness. |
Hmmm... If it plays at the same volume (in MPD I assume) that means that MPD is ignoring the R128 tags. Even if the Cantata values were wrong, I'd expect a difference between replaygain on and off. I've made a small change to the code. As is, there is no change. But can you please try:
This should update the opus header - and makes the R128 tags all 0 for me. Is the level better with this? The problem is that you can then not turn off replaygain - as the file always has it. However, this is what other appear to do... Its not compiled in by default, as I'm not sure about it yet. ...to be honest, I'm not sure about any of it. Guess I need to compile a custom MPD with proper R128 opus support. |
I compile cantata using Arch's AUR service since I am a total "noob" at compiling anything more than using ./configure make make install etc. I am not sure how I can change on .cpp file without disturbing the course of PKGBUILD's compiling. |
A lot of people on the net have been against Xiph's decision of the ebu r128 standard instead of replaygain v2 since it creates problems. replaygain v2 is, if I am correct, ebu r128 but with a higher reference volume (89 dB). EBU R128 use "23 LUFS". I wonder why they would not allow opus to have replaygain tags together with r128. |
Code updated. Can you try (once more) with untouched opus files? |
The opus file is unfortunately still louder. |
Don't think I have any players that correctly read these. Can you try:
Which of these two is better? Are either like the FLAC? |
that sounds the same between FLACs and OPUS for me with MPD 0.20.21 Also, only apply the difference (when reading tags) if the unmodified tag is not 0 Issue #1345
I build MPD 0.20.21 with libopus support. Tried 3 Cantata opus files:
1 - Volume levels matched So, for me, this issue is now (for MPD at least) resolved. |
Might be what makes the difference in volume between flac and opus.
The text was updated successfully, but these errors were encountered: