Normalizing audio in media files (video & audio)

So I've built a decent collection of movies and TV shows that I stream to my Roku from my computer using Plex and the Plex Media Server. I've noticed that the audio in some of the videos are quieter than usual, which leads me to turning the volume up just for those videos. I figured I would try to batch normalize all of the videos to see if that helps, but there doesn't seem to be a free tool that can do such a job. So what does a programmer do in this situation? He decides to try and build one himself.

Would anyone like to give me some guidance or ideas on how I can accomplish this? I have an idea about how to normalize the audio, but I'm not too sure how to deal with ask the different video/audio formats and codecs. Plus, I'm not too sure how I would apply the new normalized audio back to the video file.

I of course want to use JUCE for everything I can, such as the GUI and file handling, but I don't know if JUCE would be able to handle the different video and audio formats out there. Does anyone have any suggestions on what I can use to handle the video and audio files? I've heard about FFmpeg, but I've never used it before. Perhaps I should give it a try. Any help at all would be appreciated. There's a lot of knowledgeable folks here, so I figured I'd try and get some input from y'all.

We ceetainly don't have any way of offering full read/write of all video formats! That's a monumentally difficult task, and really the only library that does it is ffmpeg. It's a pretty horrible library to use, so good luck!

doesn't seem... optimal. I should rather make a (juce) plugin that scans the audio content for the mean (rms) value and uses this number to adjust the gain. This should be possible to do in real time as it isn't really necc to scan the whole video in advance, just a few minutes (or even seconds) should suffice. In fact, doing it in real time should make it possible to adjust the volume on the fly, should that be considered a feature.

IIRC most bluray/dvd player have this option to adjust the dynamic content for "noisy environment" which in plain language means compressing and adjusting the volume to some uniform level. I wouldn't be too surprised if there already were some code available for this rippling around in the universe of free downloads.

Hi oxxyyd, did you succeed in scanning rms in advance and adjusting gain?
I’m working on something similar and we could exchange experiences…

Simple rms doesn’t correlate very well with the human perception of loudness. Better use ITU-R BS.1770/EBU R128 (https://tech.ebu.ch/loudness) like iTunes, YouTube, Spotify and many broadcasters do nowadays. In a nutshell, it applies some filtering, determines the energy (rms) of overlapping time intervals and does some simple statistics.

I have implemented this algorithm, available at https://github.com/klangfreund/LUFSMeter/tree/master/projects/LUFSMeter/Source/ . GPLv2.

3 Likes

@samuel, I already saw your LUFS-Meter before (I was curious about the “klangfreund”-URL in your doxygen link).

But I did not see that the measurement algorithm is open source!
This is great, thanks a lot! :relieved: Also for the link to EBU…
Will check it out!

I use DSR Normalizer for video files. Works perfectly ! But outputs formats only avi or mpeg-2.