Zoog: an (experimental) tool for modifying Opus header gain 2021-01-03 17:46:08 I recently had a look at encoding some of my music into Opus having first ripped it to FLAC. When playing these files I then encountered the problem that I've seen people post about elsewhere, that the files play too quietly. After some research I found out that this was due to opusenc setting the gain value in a binary field in the Opus header to normalize the file volume according to EBU R 128 when it sees ReplayGain information in the FLAC file.I don't use a fancy player that supports R128 tags, but neither did I want to strip these tags from the FLAC before encoding since this would eliminate the R128 (R128_ALBUM_GAIN and R128_TRACK_GAIN) tags in the Opus file which might be useful later on if I migrate players.As a way to work around this on the weekend, I've written Zoog. Zoog can apply a delta to the output gain header inside an Opus stream and at the same time apply the inverse delta to the R128 tags inside the file (meaning that playback volume won't change for R128-aware players). Zoog doesn't decode the audio itself so it requires the 128_ALBUM_GAIN or R128_TRACK_GAIN tags to be present in order to determine a loudness reference. It can then alter the binary output gain value inside the file so that in a player that doesn't support R128, playback occurs at either: the volume of the source, -18 LUFS (ReplayGain), or -23 LUFS (EBU R 128).I've got generation of binaries for Linux, Windows and MacOS working, but I've only been testing on Linux. The code is also very new and untested, and could potentially corrupt files, so only use on files you have a backup of / can easily regenerate if necessary.Hopefully this tool might be of use to other Opus users who have encountered similar issues until a opusgain equivalent is available with support for setting the output-gain value as well.