I came across this answer
How can I normalize audio using ffmpeg?
However this involves transcoding the audio stream. I know that programs like
can adjust the volume losslessly, that is to say without transcoding the file. Can FFmpeg do this?
No, ffmpeg cannot apply lossless audio gain methods like ReplayGain. You have to convert the audio, and if you want it to stay lossless, you have to output to a lossless file (e.g. PCM WAV, FLAC, …).
That said, ffmpeg at least supports reading the ReplayGain data.
ffmpeg supports ReplayGain in the volume filter. If you read a file with ReplayGain metadata and convert it, you can use the ReplayGain side data to adjust the volume:
ffmpeg -i input.mp3 -af volume=replaygain=track output.wav
Here, the track volume is used. There is also album. Note that the default is to ignore ReplayGain.
If you want to read out ReplayGain data, you can just use the replaygain filter:
ffmpeg -i input.mp3 -af replaygain -f null /dev/null
Example output:
Input #0, mp3, from 'apev2-track-only.mp3':
Metadata:
encoder : Lavf57.56.100
Duration: 00:00:08.93, start: 0.025057, bitrate: 151 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 151 kb/s
Metadata:
encoder : Lavc57.64
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
Metadata:
encoder : Lavf60.16.100
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc60.31.102 pcm_s16le
[Parsed_replaygain_0 @ 0x6000029e0d10] track_gain = +13.69 dB
[Parsed_replaygain_0 @ 0x6000029e0d10] track_peak = 0.084451