0

ReplayGain is a proposed technical standard published by David Robinson in 2001 to measure and normalize the perceived loudness of audio in computer audio formats such as MP3 and Ogg Vorbis.

Does ReplayGain work on audio files encoded with Opus, too? And what's a command-line solution to apply it?

finefoot
  • 9,914
  • 7
  • 59
  • 102

1 Answers1

1

It seems that ogg (the container for opus) supports replay gain. The encoder (opusenc) also supports it, in its own very special way.

Let's take source.flac as an example. MediaInfo shows:

Album replay gain                        : -2.49 dB
Album replay gain peak                   : 0.999908
Replay gain                              : -1.94 dB
Replay gain peak                         : 0.999908

Encoding it with opusenc source.flac opusenc.opus, I get an opus file that has no replay gain information, but it plays quieter. That is, opusenc applied the gain reduction directly on the wavform, then encoded it. This is not ideal: the waveform is now compressed, not using the full 16 bits range.

Now using ffmpeg with ffmpeg -i source.flac -f wav - | opusenc - ffmpeg.opus, the waveform is preserved but the sound is loud because no replay gain tag has been added.

If I manually add the replay gain information to ffmpeg.opus (for example, using FooBar), MediaInfo shows:

R128_TRACK_GAIN                  : 140
R128_ALBUM_GAIN                  : 0

I guess that's how replay gain is encoded in ogg. Notice that it's not in dB anymore and the album gain went to zero.

Interestingly, MPC-HC on Windows does not understand flac's replay gain but can read ogg's replay gain just fine.

I don't know if we can convert the original replay gain tag to ogg's tag directly from the command line. Ffmpeg has a filter to apply replay gain (ffmpeg -i source.flac -c:a libopus -b:a 128000 -af "volume=replaygain=track" output.opus) but that does not work on ogg files (neither MPC-HC nor FooBar can read it).

Henri Zole
  • 13
  • 2