Opus files distort/clip in peaks

Issue description:

Issue: Some transcoded files distort heavily in peaks when played back in symfonium. Same transcoded file exported from symfonium and then played back in another music player (Poweramp) did not distort/clip. Noticed that playback in symfonium was louder than in Poweramp.

The same song played in symfonium as a flac does not distort.

Media provider: navidrome

Original file: flac 44.1/16

Transcoded to: 128 opus

Song: Djrum - Unweaving

Type of song: piano song

Time: multiple points but for example 1:36.

Have noticed it with other songs too.

All DSP settings are turned off, only replaygain is turned on. Prefer album, track fallback - 18 LUFS (- 23 also distorts)

Logs:

Upload description: elaiden

Additional information:

Android Samsung galaxy s23

Playback on bluetooth earbuds. Jabra Elite 8 active.

Files have been cached on the device.

I noticed when I exported the files from symfonium to test in Poweramp that the files are .flac, but the size corresponds with an opus file of 3.75mb. The original flac file Is 14mb. I tried to change the extension to opus with a simple rename and playback in Poweramp. Still no distortion then.

Reproduction steps:

Media provider:

Subsonic

Screenshots:

Increase the replay gain negative values, or enable negative pre amp or enable limiter.

Poweramp by default have negative pre amp and I think limiter enabled too. Symfonium by default ensure the most untouched natural sound.

I got very close to a solution, but not quite:

Different combinations of these 3 settings pictured below sometimes worked to remove the distortion. Mostly when they all were turned on, but sometimes when either the sample rate or the Hi-res setting was turned off. I got it to work with a second set of headphones (Sennheiser PXC 550-II). For a while, but then tried it with the jabra and couldn’t get the same result. Then when I tried with the sennheisers again the distortion was back there too, and I could not manage to get it to work there either again. Very finicky.

Other things I tried that did not work:

I tried disabling replay gain. Still distorts. It shouldn’t have made a difference since replay gain decreases the gain when enabled.

I enabled the Android DSP preamp setting (within symfonium), no matter how low I set it I still get distortion. Even tried setting it to - 15 dB. Still distorts. The music gets lower in volume, so the setting is working. But the distortion must be happening before it in the chain.

Also tried the limiter at an absurd threshold setting. Distorts. Even if it would have worked I would never want to have a limiter turned on in my listening chain..

I tried with a second set of bluetooth over ear headphones (Sennheiser PXC 550-II). Listening at a low volume to make sure the headphones are not getting overloaded, it still distorts. So its not the headphones.

So what can it be? :

It seems like somewhere in the playback chain before the DSP settings there might be an unintended gain boost after the transcode. And it does not seem to be embedded in the file, since on export the problem is gone. Although i got a bit unsure about that when I exported the file and it said .flac, Poweramp still identifies the format as being opus in the app, and it has the right size of an opus file.

I would appreciate if you could look into this, I’m an audio engineer and perfect playback that I can trust is extremely important to me. I want to hear how my mixes work when they are being transcoded with lossy compression methods, as well as in their original wav. I’m quite sure that I have checked the settings and not made an user error to cause this, though its possible.

Provide the files (original and transcoded) to https://upload.symfonium.app the transcoder you use probably add some positive base gain in the stream data.

I sent you the files with a description and some more info.

Sending the description here also:

Opus files distort/clip in peaks - music files
user: elaiden

file descriptions:

    1. Unweaving.flac = original.
  • Unweaving.flac = transcoded opus version.

  • 3 Unweaving.flac = 44.1/24 extra non transcoded i downloaded to check.

I know that the last one in 24 bit has not touched my replay gain tagger (rsgain in a docker container). If Navidrome does any gain tagging i do not know. I do not think so, since i needed to use rsgain to be able to use replay gain in symfonium. Anyway, my rsgain program has not touched it, and i still hear distortion after it has been transcoded and then played back in symfonium. When i export the one that had been transcoded from the 24 bit original, and play it back in poweramp, there is no distortion.

Listen from 1:36. At around 1:39 in the crescendo it distorts in all three files when they have been transcoded into opus and played back in symfonium.

There is a slight type of distortion in the actual song that is supposed to be there and can be heard with both files. The distortion i can hear in symfonium is much more apparent. When i play back these files on my computer and wired headphones they sound fine to me. I can hear the slight distortion in the track thats supposed to be there, but nothing like in symfonium.

Here are the 3 transcoding commands that are being used in navidrome. Pretty sure only the opus one is being used by symfonium and i see no mention of positive gain in any of them.

ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -c:a libopus -f opus -
ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -c:a aac -f adts -
ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -f mp3 -

Your files clip due to compression and their content, you should add some room in the source files.

Or use ffmpeg -i "%s" -ss %t -map 0:a:0 -c:a libopus -b:a %bk -af "volume=-2dB" -v 0 -f opus - to add room during transcoding and avoid compression clipping.

Alright got it! That fixed it, thanks. It’s not my song, so can’t add room in the source files, but the new transcoding command worked. Have you considered adding -1 to -2 of gain in the decoding stage in symfonium? That way this could also be avoided. Though i suppose nipping it in the bud as early in the chain is best. Maybe i should pester navidrome devs to change their default transcoding command instead..

That command with citation didn’t work in navidrome, this one did though:
ffmpeg -i %s -ss %t -map 0:a:0 -b:a %bk -v 0 -c:a libopus -af volume=-2dB -f opus -

Those nasty intersample peaks. Thanks!

Again Symfonium does not touch the audio unless necessary. And in all cases doing this at the transcode phase ensure better handling of your specific files issue.

1 Like