"loudnorm" (ffmpeg) filter?

General questions or discussion about HandBrake, Video and/or audio transcoding, trends etc.
Post Reply
az2020
Posts: 12
Joined: Thu Jun 03, 2021 3:22 pm

"loudnorm" (ffmpeg) filter?

Post by az2020 »

I'm encoding a DVD rip (mpeg2, ac3, ripped with MakeMKV) to h264, aac. Therefore, I thought I could use the audio tab's DRC to normalize the audio. It didn't seem like it was doing anything (more about that in a moment). Googling for other ideas, I found a really informative Superuser answer. Option 3 works very well.[1] That's pretty much exactly what I was looking for.

However, it mentions (Option 1) a "loudnorm" filter (EBU R128). I googled about that, and found a not-too-dense overview. I've been playing with that, and might like it better.

My question is: is there any way I can tell handbrake (1.3.3) to invoke that during encode? (How much is handbrake a front-end to ffmpeg? Can ffmpeg parms be passed? Can this one?).

It's a two-pass process. I have to run it once to analyze and get the parameters for the final exectuion (which I'm hoping would be the same execution as handbrake encoding of the ripped mpeg2 file to h264 and aac. Or, is this something I have to do after the video encode? I'd do ac3-passthrough with the video encode, then do an ac3 to aac ffmpeg conversion where I'd invoke this "loudnorm" filter?).

Note: when I found option 3, I used that ffmpeg analyze command to compare the audio gain of handbrake's re-encode, when I told it to use DRC=2 (a medium value). There was no difference. Not a single bit. Even the histogram values were the same. I suspect that means the DVD's ac3 stream doesn't have any hints to work from(?).

[1] Run ffmpeg -i input_file.mkv "volumedetect" -vn -sn -dn -f null /dev/null . This will report the "mean" and "max" volume. If the max is -9.3, then target 0max by adjusting the handrake>audio>gain +9. Target 0 max. (Or, target a constant mean volume so all videos sound equally loud. Maybe -26 -).
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: "loudnorm" (ffmpeg) filter?

Post by Woodstock »

mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: "loudnorm" (ffmpeg) filter?

Post by mduell »

az2020 wrote: Fri Jun 11, 2021 8:52 pmMy question is: is there any way I can tell handbrake (1.3.3) to invoke that during encode? (How much is handbrake a front-end to ffmpeg? Can ffmpeg parms be passed? Can this one?).
Not in any way, shape, or form. They use some libraries in common (including libavfilter, libavformat, x264, and x265), that's all.
az2020
Posts: 12
Joined: Thu Jun 03, 2021 3:22 pm

Re: "loudnorm" (ffmpeg) filter?

Post by az2020 »

Thank you for your answers. I understand now.

I'm having some challenge translating the gui encode log into a command-line. I may start a new thread. But, this one fits here:

Code: Select all

      --normalize-mix     Normalize audio mix levels to prevent clipping.
              <string>     Separate tracks by commas.
                           0 = Disable Normalization (default)
                           1 = Enable Normalization
The command-line syntax mentions that. The gui log mentions "NormalizeMixLevel=false". But, I don't see an option in handbrake gui's audio tab.

My opening post was about how I was expecting something different than DRC (which seems to depend on hints in the ac3 audio). I'm wondering if this normalize-mix is what I was looking for? (Is that only available cli?).

I'm really liking that ffmpeg command line to report the video's max and mean volume (the footnote of my original post). I was killing myself listening to different db gain boosts, "yeah, yeah.... that's better...." (And then the DRC wasn't doing anything that I can see. But, I spent a couple days "yeah, yeah, I hear it."). It's so nice to have a concrete number. I can look at video and see better/worse. But, my ears aren't like that.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: "loudnorm" (ffmpeg) filter?

Post by mduell »

The CLI is definitely the better interface, with all the features historically; the GUI is angry spaghetti for noobs.
Post Reply