View Full Version : DynamicAudioNormalizer
smok3
31st July 2017, 11:28
Anyone using loudnorm and if so with what settings? Defaults are kinda ok, if a little sissy (lacks a bit of dynamics).
Have this in mpv input.conf
F1 cycle-values af "lavfi=[dynaudnorm=s=30]" "lavfi=[loudnorm]" ""
manolito
31st July 2017, 14:00
The effect of LoudNorm depends a lot on the parameters, it goes from subtle to very strong dynamic compression.
These are the FFmpeg defaults:
I, i
Set integrated loudness target. Range is -70.0 - -5.0. Default value is -24.0.
LRA, lra
Set loudness range target. Range is 1.0 - 20.0. Default value is 7.0.
TP, tp
Set maximum true peak. Range is -9.0 - +0.0. Default value is -2.0.
The target Integrated loudness is quite low, it complies to the ATSC standard. For EBU R128 it would be -23, for ReplayGain it is -18.
The target loudnesss range is small, it results in a strong dynamic compression.
True peak is OK, maybe it could be increased a little to -1.5 or even -1.
There is a GUI for LoudNorm called WinLoud (by Muxson). His defaults are optimized for podcasts, see them here:
http://www.muxson.com/winloud
The author of Loudnorm prefers different values again:
http://k.ylo.ph/2016/04/04/loudnorm.html
And myself I do not want too strong dynamic compression, and my target level is Replaygain. So I use
Target Integrated Loudness: -18 LUFS
Target Loudness Range: 14 dB
Target True Peak Level: -1.5 SPFS
Takes a little experimentation to find your preferred settings.
Cheers
manolito
smok3
31st July 2017, 15:17
Hmm, 7dB seems like it should be enough of dynamics, I guess I'll have to measure and compare that with something. p.s. I don't use anything-win.
LoRd_MuldeR
31st July 2017, 21:52
The loudness values are almost identical for both conversions. At least for "sane" source audio levels it is not necessary to apply regular peak normalization before DynAudNorm.
Yes, with a properly produced/leveled recoding, the "loudest" peaks in the file should already be at maximum signal level, or just below the maximum signal level.
In that situation a "traditional" (non-dynamic) normalizer will do exactly nothing, because the "loudest" peaks prevent further amplification without clipping. But a tool like DynAudNorm (or maybe LoudNorm) might be used to bring up the "quiet" sections a little more – provided that there are some long enough "quiet" sections that are significant quieter than the "loudest" sections. Still, after such processing, a "traditional" (non-dynamic) normalizer will again do exactly nothing, because the "loudest" peaks still are at maximum signal level (or just below) and therefore further amplification is still prevented. Summary: With a properly produced/leveled recoding, a "traditional" normalizer is pretty pointless.
My point was: If you have a poorly leveled recording, where even the "loudest" peaks are way below the maximum signal level, i.e. the recording does not utilize the complete signal range, then the first step should be using a "traditional" (non-dynamic) normalizer in order to get rid of the unused "headroom". A tool like DynAudNorm is not needed (and probably not the best choice) for that purpose. If and only if, after the "traditional" (non-dynamic) normalization you still think that the volume of the "quiet" sections should be brought up more closely to the "loud" sections, then a tool like DynAudNorm is the right tool. Used in the right way, a max. amplification factor of 100× should be more than you'll ever need.
hydra3333
2nd September 2017, 11:54
Anyone using loudnorm and if so with what settings? Defaults are kinda ok, if a little sissy (lacks a bit of dynamics),
Not sure if this is what you mean ... I use loudnorm in ffmpeg to try to adjust recordings all to a usable level. Here's the code lifted directly from my script without all relevant variables defined, so buyer beware.
REM snip
set audiofreq=48000
set audiobitrate=384k
SET audiodelayadjms=010
set AudioDelayms=000
REM audiodelayadjms delays audio just a tad extra .01s so that it comes out after the lips move
REM AudioDelayms is the final calculated delay for audio with audiodelayadjms added to it
SET lI=-16
SET lTP=0.0
SET lLRA=11
REM snip
REM to adjust Audio volume. find the loudness parameters in a first pass
ECHO !DATE! !TIME! ***************************** start Find Audio Loudness ***************************** >> "%vrdlog%" 2>&1
ECHO file "%~f1" ...
ECHO "%ffmpegexex64%" -threads 0 -nostats -nostdin -y -hide_banner -threads 0 -i "%~1" -vn -threads 0 -af loudnorm=I=%lI%:TP=%lTP%:LRA=%lLRA%:print_format=json -threads 0 -f null - >> "%vrdlog%" 2>&1
"%ffmpegexex64%" -threads 0 -nostats -nostdin -y -hide_banner -threads 0 -i "%~1" -vn -threads 0 -af loudnorm=I=%lI%:TP=%lTP%:LRA=%lLRA%:print_format=json -threads 0 -f null - 2> "%jsonFile%"
SET EL=!ERRORLEVEL!
IF /I "!EL!" NEQ "0" (
Echo ********* Error !EL! was found >> "%vrdlog%" 2>&1
Echo ********* Error !EL! was found >> "%vrdlog%" 2>&1
Echo ********* Error !EL! was found
Echo ********* ABORTING ... >> "%vrdlog%" 2>&1
%xpause%
EXIT !EL!
)
REM all the trickery below is simply to remove quotes and tabs and spaces from the json single-level response
set input_i=
set input_tp=
set input_lra=
set input_thresh=
set target_offset=
for /f "tokens=1,2 delims=:, " %%a in (' find ":" ^< "%jsonFile%" ') do (
set "var="
for %%c in (%%~a) do set "var=!var!,%%~c"
set var=!var:~1!
set "val="
for %%d in (%%~b) do set "val=!val!,%%~d"
set val=!val:~1!
REM echo .!var!.=.!val!.
IF "!var!" == "input_i" set !var!=!val!
IF "!var!" == "input_tp" set !var!=!val!
IF "!var!" == "input_lra" set !var!=!val!
IF "!var!" == "input_thresh" set !var!=!val!
IF "!var!" == "target_offset" set !var!=!val!
)
echo input_i=%input_i% >> "%vrdlog%" 2>&1
echo input_tp=%input_tp% >> "%vrdlog%" 2>&1
echo input_lra=%input_lra% >> "%vrdlog%" 2>&1
echo input_thresh=%input_thresh% >> "%vrdlog%" 2>&1
echo target_offset=%target_offset% >> "%vrdlog%" 2>&1
REM check for bad loudnorm values ... if baddies found, use dynaudnorm instead
set AUDprocess=loudnorm
IF /I "%input_i%" == "inf" (set AUDprocess=dynaudnorm)
IF /I "%input_i%" == "-inf" (set AUDprocess=dynaudnorm)
IF /I "%input_tp%" == "inf" (set AUDprocess=dynaudnorm)
IF /I "%input_tp%" == "-inf" (set AUDprocess=dynaudnorm)
IF /I "%input_lra%" == "inf" (set AUDprocess=dynaudnorm)
IF /I "%input_lra%" == "-inf" (set AUDprocess=dynaudnorm)
IF /I "%input_thresh%" == "inf" (set AUDprocess=dynaudnorm)
IF /I "%input_thresh%" == "-inf" (set AUDprocess=dynaudnorm)
IF /I "%target_offset%" == "inf" (set AUDprocess=dynaudnorm)
IF /I "%target_offset%" == "-inf" (set AUDprocess=dynaudnorm)
REM
REM later, in a second encoding pass we MUST down-convert from 192k (loadnorm upsamples it to 192k whis is way way too high ... use -ar 48k or -ar 48000
REM
IF /I "%AUDprocess%" == "loudnorm" (
ECHO "Proceeding with normal LOUDNORM audio normalisation ..." >> "%vrdlog%" 2>&1
ECHO "Proceeding with normal LOUDNORM audio normalisation ..."
set loudnormfilter=loudnorm=I=%lI%:TP=%lTP%:LRA=%lLRA%:measured_I=%input_i%:measured_LRA=%input_lra%:measured_TP=%input_tp%:measured_thresh=%input_thresh%:offset=%target_offset%:linear=true:print_format=summary
echo "loudnormfilter=%loudnormfilter%" >> "%vrdlog%" 2>&1
) ELSE (
ECHO "********* ERROR VALUES DETECTED FROM LOUDNORM - Doing UNUSUAL dynaudnorm audio normalisation instead ..." >> "%vrdlog%" 2>&1
ECHO "********* ERROR VALUES DETECTED FROM LOUDNORM - Doing UNUSUAL dynaudnorm audio normalisation instead ..." >> "%vrdlog%" 2>&1
ECHO "********* ERROR VALUES DETECTED FROM LOUDNORM - Doing UNUSUAL dynaudnorm audio normalisation instead ..."
ECHO "********* ERROR VALUES DETECTED FROM LOUDNORM - Doing UNUSUAL dynaudnorm audio normalisation instead ..."
set loudnormfilter=dynaudnorm
echo "loudnormfilter=%loudnormfilter% (Should be dynaudnorm)" >> "%vrdlog%" 2>&1
)
ECHO !DATE! !TIME! ***************************** end Find Audio Loudness ***************************** >> "%vrdlog%" 2>&1
REM ------------------------------ audio conversion ------------------------------
echo !DATE! !TIME! ***************************** start ffmpeg %makeaudiotype% AUDIO conversion ***************************** >> "%vrdlog%" 2>&1
REM mp3 audio conversion "%~f1" ...
IF /I "%makeaudiotype%" == "mp3" (
ECHO mp3 audio conversion "%~f1" ... >> "%vrdlog%" 2>&1
ECHO mp3 audio conversion "%~f1" ...
ECHO "%ffmpegexex64%" -threads 0 -nostats -threads 0 -i "%~1" -threads 0 -vn -threads 0 -map_metadata -1 -af %loudnormfilter% -c:a libmp3lame -ab %audiobitrate% -ar %audiofreq% -threads 0 -y "%parmp3%" >> "%vrdlog%" 2>&1
"%ffmpegexex64%" -threads 0 -nostats -threads 0 -i "%~1" -threads 0 -vn -threads 0 -map_metadata -1 -af %loudnormfilter% -c:a libmp3lame -ab %audiobitrate% -ar %audiofreq% -threads 0 -y "%parmp3%" >> "%vrdlog%" 2>&1
SET EL=!ERRORLEVEL!
IF /I "!EL!" NEQ "0" (
Echo ********* Error !EL! was found >> "%vrdlog%" 2>&1
Echo ********* Error !EL! was found >> "%vrdlog%" 2>&1
Echo ********* Error !EL! was found
Echo ********* ABORTING ... >> "%vrdlog%" 2>&1
%xpause%
EXIT !EL!
)
)
REM aac audio conversion "%~f1" ...
IF /I "%makeaudiotype%" == "aac" (
ECHO aac audio conversion "%~f1" ... >> "%vrdlog%" 2>&1
ECHO aac audio conversion "%~f1" ...
ECHO "%ffmpegexex64%" -threads 0 -nostats -threads 0 -i "%~1" -threads 0 -vn -threads 0 -map_metadata -1 -af %loudnormfilter% -c:a libfdk_aac -cutoff 18000 -ab %audiobitrate% -ar %audiofreq% -threads 0 -y "%paraac%" >> "%vrdlog%" 2>&1
"%ffmpegexex64%" -threads 0 -nostats -threads 0 -i "%~1" -threads 0 -vn -threads 0 -map_metadata -1 -af %loudnormfilter% -c:a libfdk_aac -cutoff 18000 -ab %audiobitrate% -ar %audiofreq% -threads 0 -y "%paraac%" >> "%vrdlog%" 2>&1
SET EL=!ERRORLEVEL!
IF /I "!EL!" NEQ "0" (
Echo ********* Error !EL! was found >> "%vrdlog%" 2>&1
Echo ********* Error !EL! was found >> "%vrdlog%" 2>&1
Echo ********* Error !EL! was found
Echo ********* ABORTING ... >> "%vrdlog%" 2>&1
%xpause%
EXIT !EL!
)
)
echo !DATE! !TIME! ***************************** end ffmpeg %makeaudiotype% AUDIO conversion ***************************** >> "%vrdlog%" 2>&1
REM snip
Sill reconsidering dynanorm as the default.
smok3
4th September 2017, 15:22
^ That any different than ˇ ?
mpv --af=lavfi=[loudnorm] file.mp4
edit: Oh I see, your LRA is higer than default.
To test:
af=lavfi=[loudnorm=LRA=10]
osgZach
12th December 2017, 04:02
Just a quick question, and an observation if you will... (this is a big thread)
Q: How concurrent is the ffmpeg filter with your source builds? In terms of any major improvements. I'm probably going to be writing myself a huge script of some sort, or maybe even a program, to automate batch processing of audio tracks from movies (I'm trying to automate the whole encoding chain really, video, subs, etc), so the less tools I have keep track of the better. Keeping it all inside ffmpeg would be preferable.
The observation: I think someone may have posted something similar to this a few pages back, but I've pretty much been up and down the race track trying out different methods of downmixing multichannel (5.1, 7.1) audio tracks to Stereo and avoiding the dynamic range problems associated with it. At first when I was playing with dynaud in ffmpeg, I wasn't noticing much difference, then I downloaded the CLI off Mulder's repo, and noticed a big improvement in reaching what I was trying to achieve.
The one major difference was when I used Mulder's CLI I was operating on a Stereo track generated from ffmpeg with -ac 2. while trying the filter in ffmpeg though I was feeding it the AC-3 source directly though (I did throw -ac 2 before the filter also). There is a distinct difference in my opinion. So I re-ran the Stereo track through ffmpeg and got pretty much the same result as using the separate CLI . I'm not an audio expert by any means, but I would say there is around a 1dB difference or more in loudness. Is there a reason for that?
It seems like for my workflow I need to generate a Stereo track as an intermediate file, and then re-filter that file to get my final output.
It goes pretty fast so I don't really care, just found it odd.
if needed I can probably find some time to trim a sample clip and provide an example package if that suits you.
sneaker_ger
12th December 2017, 12:18
(I did throw -ac 2 before the filter also)
Does this really ensure the down-mix comes before the audio filtering (e.g. dynaudnorm)? I guess not.
LoRd_MuldeR
12th December 2017, 15:13
Just a quick question, and an observation if you will... (this is a big thread)
Q: How concurrent is the ffmpeg filter with your source builds? In terms of any major improvements.
There haven't been any significant improvements to the "core" algorithm, only a few fixes here and there.
kolamorx
7th May 2018, 12:32
Hello.
I've read your documentation about the maximum gain factor, that ususally it's not recommended to increase the value above the default but sometimes it may be necessary to allow higher gain factors.
So if I understood correctly (and from my experience), when you have to allow higher gain factors, it's better to set it as less value as possible.
What free tool for Windows do you recommend for volume measurement, so I can get data about the dialogue volume levels in some scenes per movie (which sometimes are very low), in order to set the maximum gain factor as less value as possible?
LoRd_MuldeR
7th May 2018, 19:02
Hello.
I've read your documentation about the maximum gain factor, that ususally it's not recommended to increase the value above the default but sometimes it may be necessary to allow higher gain factors.
So if I understood correctly (and from my experience), when you have to allow higher gain factors, it's better to set it as less value as possible.
No matter what you do, the gain factor for each frame will never be allowed to exceed the frame's local max. gain factor – the maximum that this particular frame could be amplified without any clipping (distortion).
Furthermore, the actual gain factor applied to a frame will usually be even lower than the "local max. gain factor", because we apply a minimum filter followed by a Gaussian smoothing filter to each "neighborhood" (sliding window) of frames.
The "max. gain factor" option is an additional hard limit on the maximum gain factor that can be applied to frame. This mostly exists to avoid humongous amplification factors in extremely quiet (almost silent) sections of the file.
What free tool for Windows do you recommend for volume measurement, so I can get data about the dialogue volume levels in some scenes per movie (which sometimes are very low), in order to set the maximum gain factor as less value as possible?
This tool, for example, can create a graph of the "loudness" (ITU BS.1770 and CBS) of a given file:
https://www.orban.com/meter/
kolamorx
8th May 2018, 12:24
No matter what you do, the gain factor for each frame will never be allowed to exceed the frame's local max. gain factor – the maximum that this particular frame could be amplified without any clipping (distortion).
I know it, that's not what I meant.
Let me put it this way: if I set the maximum gain factor to too high value for a certain movie, sounds like breathing could have too high volume and that's a problem.
On the other hand, if I set the maximum gain factor to too low value for a certain movie, the dialogue volume could be too low comparing to the sound effects and music volume and that's a problem too.
Am I right?
LoRd_MuldeR
8th May 2018, 18:53
I know it, that's not what I meant.
Let me put it this way: if I set the maximum gain factor to too high value for a certain movie, sounds like breathing could have too high volume and that's a problem.
On the other hand, if I set the maximum gain factor to too low value for a certain movie, the dialogue volume could be too low comparing to the sound effects and music volume and that's a problem too.
Am I right?
Nope, not really.
The DynamicAudioNormalizer will amplify each part of the file, which is quieter than the target volume, so that it is brought up to the target volume. Also it will attenuate each part of the file, which is louder than the target volume (if any such part exists), so that it is brought down to the target volume. In the end, all parts of the file will have "equal" volume. Of course, that all combined with Gaussian smoothing in order to avoid fast fluctuation of the gain factors.
Now, what the "maximum gain factor" option really does: It imposes an additional limit on how much a "quiet" frame may be amplified in order to reach the desired target volume. The default "maximum gain factor" value, which is 10.0×, should be enough for most needs. But it can, of course, be increased, if it should really be needed. Anyhow, probably the vast majority of your frames (if not all of them!) will not need more amplification than what the default "maximum gain factor" value allows. And again: This is only an upper limit, not the actual amount of gain that will be applied! The actual gain factor will be determined dynamically for each frame, and it probably will be way lower than the limit in most cases!
The "maximum gain factor" limit exists primarily in order to avoid humongous amplification factors in extremely quiet (almost silent) sections of the file. If there was no such limit, it could easily result in excessive amplification factors in those extremely quiet sections – which you do not want. If we'd amplify extremely quiet (almost silent) sections by such an excessive amount, the result will sound very "noisy", because the quantization noise becomes audible...
(I suggest you let DynamicAudioNormalizer write a log file and inspect that log file in DynamicAudioNormalizer GUI, which will easily show whether you run into the limit or not)
JuliusJac
19th December 2018, 15:43
Hei,
I know this Thread is rather old. But I have been searching the internet, and tried myself for 2 full days :( with almost no result. We have several hundred videofiles where the "volume" changes within the soundtrack. And I was trying all/a lot. But no loudnowm or dynaudnorm setting I use seems to giv an acseptable result.? can anyone Help me?
Here is one of the arguments I tried:
$ ffmpeg -i testin.mp3 -af "dynaudnorm=p=0.8:m=25:r=0.5"
Here one of our examples
testin.mp3 (https://drive.google.com/open?id=1fB2QYYf94PbJ9PvNdsbwC8Uw3vjfP3KD)
THANKS and Greetings from Norway
LoRd_MuldeR
19th December 2018, 16:50
Hei,
I know this Thread is rather old. But I have been searching the internet, and tried myself for 2 full days :( with almost no result. We have several hundred videofiles where the "volume" changes within the soundtrack. And I was trying all/a lot. But no loudnowm or dynaudnorm setting I use seems to giv an acseptable result.? can anyone Help me?
Here is one of the arguments I tried:
$ ffmpeg -i testin.mp3 -af "dynaudnorm=p=0.8:m=25:r=0.5"
Here one of our examples
testin.mp3 (https://drive.google.com/open?id=1fB2QYYf94PbJ9PvNdsbwC8Uw3vjfP3KD)
THANKS and Greetings from Norway
Hello.
Well, what are you trying to achieve? Or what is wrong with DynAudNorm default settings?
DynAudNorm was designed to retain the "dynamics" that exist in each local neighborhood, so that the characteristics of the original audio are preserved. Default settings have been chosen rather conservative.
Anyway, if you want to force DynAudNorm to act more "aggressively", first try decreasing the filter size ("--gauss-size" option). Default is 31, but you may want to try something like 11.
In addition to that, you may also try decreasing the frame length ("--frame-len" option). Default is 500 ms, but you could try 250 ms or even 125 ms. Note that filter size is expressed in frames, so these option mutually influence each other!
(I'm writing about the DynAudNorm CLI options here, because I'm more familiar with that one than with the FFmpeg port, but things should work for FFmpeg just the same way)
Your original:
https://i.imgur.com/LLJtA2d.png?1
DynAudNorm default settings:
https://i.imgur.com/wF3i76R.png?1
More aggressive settings (filter size reduced to 11):
https://i.imgur.com/Pcp2fpm.png?1
Something extreme (filter size reduced to 5 + frame length reduced to 125):
https://i.imgur.com/AGq8Mt9.png?1
JuliusJac
20th December 2018, 10:53
Hi LoRd_MuldeR
Thanks for your time!
I tuned the values in to the opposit direcction;)
for instance in this audiofine we have the periode 43-54sec and 54-69sec where the volume is is compleatly different. (manly due to the fact of a complete differnet sound)
Is there a way of eventing out this differance evan more?
LoRd_MuldeR
20th December 2018, 13:57
for instance in this audiofine we have the periode 43-54sec and 54-69sec where the volume is is compleatly different. (manly due to the fact of a complete differnet sound)
Is there a way of eventing out this differance evan more?
Well, in theory, you can go as low as "--gauss-size 3" and "--frame-len 10" – but be aware that, at some point, audio quality is going to suffer severely!
You will have to do some experiments in order to find the "sweet spot" for you needs :)
In addition to that, you may try the "--compress" option, which is going to prune the "loudest" samples prior to the actual normalization. Note that, here too, smaller parameter values result in stronger compression.
(Be aware: extreme compression values are going to distort the audio quality!)
I tuned the values in to the opposit direcction;)
See also:
http://muldersoft.com/docs/dyauno_readme.html#configuration
Emulgator
14th July 2019, 20:08
I just want to say thank you and give it a test:
But where am I stuck ?
On startup the DAN GUI.exe wants to see the path to a logfile that doesn't exist yet.
Any option I press then leads to closing of the program.
I faked a logfile to get into it and probably access settings, but: it opened the logviewer, if I close it: no GUI open anymore.
LoRd_MuldeR
14th July 2019, 21:12
I just want to say thank you and give it a test:
But where am I stuck ?
On startup the DAN GUI.exe wants to see the path to a logfile that doesn't exist yet.
Any option I press then leads to closing of the program.
I faked a logfile to get into it and probably access settings, but: it opened the logviewer, if I close it: no GUI open anymore.
Sorry, the GUI program is just to show (visualize) existing log files:
http://muldersoft.com/docs/img/dyauno/Chart.png
You have to use the CLI program for processing audio data; it can optionally produce a log file:
http://muldersoft.com/docs/dyauno_readme.html#command-line-usage
If you want a GUI, you are probably better off by using the VST plug-in:
http://muldersoft.com/docs/dyauno_readme.html#vst-plug-in-usage
Emulgator
15th July 2019, 23:12
Ah thanks, that clears it up.
Munching...
Audacity 2.3.2. sees, but refuses to load DAN VST.dll
SoundForge11 does not see DAN VST.dll
At only 42KB the .dll is quite small. Missing dependencies ?
Solved: I should have used the shared .dll of course. Now both DAWs can see and use DAN.
Awsome work, Lord Mulder !
Just applied it to the sound track of a just restored 1961 movie using the defaults.
Gets the (normally tedious manual) work beautifully done, keeping the quiet/loud ratio convincing, no pulling gain up in quiet parts.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.