desbma / r128gain

Fast audio loudness scanner & tagger (ReplayGain v2 / R128)
GNU Lesser General Public License v2.1
170 stars 9 forks source link

Is there a way to get a + sign for positive values, when using Ffmpeg to adjust gain it doesn't work without them. #29

Closed simcc closed 3 years ago

simcc commented 3 years ago

For example, using "ffmpeg -i input.mp4 -c:v copy -af volume=replaygain=track output.mp4" if the track gain is 31.43, as it comes out of r128gain, nothing happens, whereas, if I open up the file in Mp3tag etc. and add in a + sign in front of the 31.43 (+31.43), it then works.

desbma commented 3 years ago

Please clarify your question, as I have trouble to understand how it is related to r128gain.

simcc commented 3 years ago

I guess it's more a feature request...so for example, when you analyse a track with r128gain, negative values for replay_track_gain have a - sign (i.e. -2.10 etc.), whereas positive values have no symbol (i.e. 9.70 etc.). Would it be possible to have an option to add a + sign to positive values, so 9.70 would be +9.70 for example.

The reason being, when you try to adjust the gain of a file with ffmpeg using replaygain (e.g. ffmpeg -i input.m4a -af volume=replaygain=track output.m4a etc.), it won't recognise a positive value unless it has a plus sign.

Basically I'm using r128gain to calculate replay_track_gain values and then printing those adjustments with ffmpeg...hoping to batch process over a thousand files, and it's all working, but this one thing is breaking it.

desbma commented 3 years ago

The RGv2 specification clearly mentions the format of the tags, and it should not contain a '+' char.

If your goal is to apply gain (as opposed to tagging) on files with FFmpeg, you dot not actually need r128gain because it internally uses FFmpeg for all audio computations (ebur128 filter among many others), so you should be able to do what you want with only FFmpeg and a few scripting.

simcc commented 3 years ago

Yeah in fairness this is an ffmpeg bug tbh. Cheers anyway.

Yeah I might do it that way, there's loads of ways of course...but since I have a bunch of audio files and videos all in the same archive, it would be handy to use r128gain on everything...

desbma commented 3 years ago

r128gain's function is to tag files with RGv2 tags or RGv1 when it is compatible, for dynamic loudness ajustments by media players or playback devices. I will not add an option to generate non compliant tags, so I am closing this.

If your goal is to normalize files by applying gain directly, you are clearly making it more complex than it needs to be though. You can do it all in one step without tagging files, for example with the FFmpeg loudnorm filter which is made for that purpose and uses the same R128 loudness calculation. I assume you already know, but be aware this is a lossy processing.

simcc commented 3 years ago

Yeah no worries...there's a couple of reasons why I wanted to use replaygain tags, no point going into it...like I said, you're right that it's not spec, whoever wrote the FFmpeg "volume=replaygain=track" got it wrong...