Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd August 2018, 09:35   #1  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
Loudness Correction for Broadcast

I gotta encode files at -24LUFS.
So far, I didn't really pay attention to loudness in Avisynth or ffmpeg 'cause I handled that separately using Sony DP600, however, the amount of files that need to be encoded increased, so the DP600 can't keep the peace and apply loudness correction to each file we encode, especially 'cause it's slow as hell (pretty much 1:1).
I tried to do something like:

ResampleAudio(48000)
Normalize(0.12)
ConvertAudioTo24bit()

I ended up with an extremely low audio.
In other words, ResampleAudio and Convert are fine, but Normalize basically limits audio using the peak, which ends up in outputting undesired results, 'cause with Normalize(0.12), the highest peak is -24LUFS and all the other parts of the audio track are lowered accordingly, which led to extremely low audio and this is not what I wanted. The purpose of having -24LUFS is not to limit the peak (true peak), but to have an almost constant loudness across the time, with occasional high peaks, but with a medium of -24LUFS. For instance, if there are many explosions and is an action movie, the medium of the loudness may be -20 or -18 LUFS which is fine due to the high amount of peaks.

Since Normalize didn't achieve the results I hoped, I tried:

Avisynth:
ResampleAudio(48000)
ConvertAudioTo24bit()

FFMpeg:
-af loudnorm=I=-24:LRA=1


The output is actually better than using Normalize, but still, it's not exactly what I wanted.
Is there a way to achieve it in Avisynth?
Is there a filter to achieve a good loudness correction like the one done by professional broadcast encoder like Sony DP600?

Thank you in advance.

Last edited by FranceBB; 23rd August 2018 at 09:37.
FranceBB is offline   Reply With Quote
Old 23rd August 2018, 17:31   #2  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
As a "Broadcast Encoder" you probably know more about the EBU R128 or BS1770 standards than I do. I guess I do not need to explain that applying these standards DOES NOT alter the dynamic range of the source, i.e. no DRC is used. It is a 2-pass process where the first pass scans the entire source to determine the loudness (measured in LUFS), then the second pass applies a gain to reach the target loudness (-24 LUFS for ATSC A/8, -23 LUFS for EBU R128 and -18 LUFS for ReplayGain2).

The problem is that there is no protection against clipping. If you do get clipping then you can either reduce the gain (but then you will not reach your desired target LUFS), or you can apply DRC first to reduce the peaks.

The Loudnorm filter for FFmpeg tries to do both. I think that you should not use "LRA=1", this will limit the target loudness range way too much. I usually use "LRA=14" with good results. Also in 1-pass mode the resulting audio will mostly not reach your desired loudness, you need to use 2-pass mode for more exact results.

There is a nice front end for Loudnorm written by Muxson.
http://www.muxson.com/winloud


If you do not want any DRC then I (reluctantly) recommed "BS1770Gain". I use the stable version 0.4.11. This tool analyzes multiple source files at once and gives you the appropriate gain correction values. Here is a small batch file to automate the process:

Analyze.bat
Quote:
@ECHO off

SET EBU_DRIVE=%~d0
SET EBU_PATH=%~p0
%EBU_DRIVE%
CD "%EBU_PATH%"

bs1770gain.exe --atsc -itr --loglevel "quiet" %*
ECHO.
ECHO.
ECHO.
PAUSE
Put this batch file into the folder where BS1770Gain resides. Then just Drag&Drop or Copy&Paste one or multiple source files on the batch file.

Cheers
manolito

Last edited by manolito; 26th August 2018 at 00:58. Reason: Replaced Sample Peak with TruePeak
manolito is offline   Reply With Quote
Old 24th August 2018, 10:06   #3  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
Quote:
The problem is that there is no protection against clipping. If you do get clipping then you can either reduce the gain (but then you will not reach your desired target LUFS), or you can apply DRC first to reduce the peaks.
They would probably end up as "outcome TBC" once I send them to QC if I brutally clip without applying a proper dynamic range compression first.
Our QC rooms are equipped with two Sony LM-100 and operators listen to each contents with high-end professional headsets.
That's mainly why I was reluctant to use anything other than the DP600, but I'm gonna try with the loudnorm filter at LRA 14 and two-pass.
It's probably gonna be enough for general purpose stereo contents, which is still fine, even thought it might not be enough for 5.1 action contents, 'cause they need to be handled carefully, especially the Center Channel, which is why we created specific profiles aimed to preserve the speech ('cause otherwise you would end up with gun shots and explosions that are far too high and get normalized at the expense of the speech that gets too low).
I don't think that the ffmpeg loudnorm filter is speech-aware, 'cause I only see the options to set the loudness range target, true peak and a few other settings not particularly related to speech.
I've seen far too many movies wrongly encoded this way...
Anyway, I'm gonna make a few tests. Hopefully it's gonna be helpful for many contents. ^_^

Last edited by FranceBB; 24th August 2018 at 10:10.
FranceBB is offline   Reply With Quote
Old 24th August 2018, 17:58   #4  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Also made a few tests with -24 LUFS as the target loudness. The source was a short test clip with very low volume to emphasize the clipping problem with EBU R128 Loudness Normalization. Here are the results:

Quote:
Source:
[1/1] "test.mp4":
integrated: -35.97 LUFS / 11.97 LU
true peak: -6.70 TPFS / 0.462219

EBU R128 with clipping protection:
[1/1] "DVD_test_1.ac3":
integrated: -29.23 LUFS / 5.23 LU
true peak: -0.00 TPFS / 0.999706

EBU R128 with SoX DRC preprocessing (using Compand):
[1/1] "DVD_test_1.ac3":
integrated: -24.00 LUFS / 0.00 LU
true peak: -1.56 TPFS / 0.835995

LoudNorm 2-pass:
[1/1] "test-WinLoud.wav":
integrated: -23.91 LUFS / -0.09 LU
true peak: -0.97 TPFS / 0.894259
Using EBU R128 with clipping protection is unable to reach the -24 LUFS target loudness, but in the real world this method often sounds better than the methods with DRC, because this audio clip was probably intended to be listened to at a lower volume.

Multichannel audio should be treated well with the EBU or BS1770 scanning method. K-Weighting, Channel Summing und Gating are employed with this method, you can find a very nice explanation here:
https://www.delamar.de/mastering/r128-14870/

And dealing with Dialog Normalization is certainly not the task of Loudness Normalization. These things are separate problems and need to be dealt with separately.

Cheers
manolito

Last edited by manolito; 24th August 2018 at 18:29.
manolito is offline   Reply With Quote
Old 24th August 2018, 21:36   #5  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
I use foobar2000. It's ReplayGain scanner uses the R128 algorithm and it'll save the info as ReplayGain tags. It saves them in ReplayGain-speak, but ReplayGain's 89dB target volume is the same as -18 LUFS and -24 LUFS is 6dB lower.

Once you've scanned you can save the info to just about any file type, even AC3 and DTS, then apply it while converting. There's a "prevent clipping according to the peak" option but that requires lowering the overall volume for audio where the peaks would clip, so I usually convert and scan the output files to check the peaks.

None of the audio in the first screenshot below will clip after the volume is adjusted as they'll all be reduced, aiming for a Track Gain of +6dB (the ReplayGain scan after adjusting the volume should show they need a 6dB increase to achieve the standard ReplayGain target volume, as it's 6dB higher than -24 LUFS).
After scanning the converted files, if any have peaks of 0dB or greater (even 0dB indicates the peaks were probably clipped, especially for lossless formats such as 16/24 bit wave files) I re-encode those source files with a DSP in the chain to increase the volume by one or two dB, followed by foobar's Advanced Limiter, then a DSP to reduce the volume by the same amount as before (the Advanced Limiter doesn't kick in until 0db, so increasing the volume a bit first effectively makes it kick in earlier than 0dB).

If you use DSPs that alter the volume (or the Dynamic Audio Normalizer etc), obviously that requires intermediate files before scanning and converting to adjust to -24 LUFS.

I normally only work with stereo audio, but I included a 5.1ch file to confirm the scan result is correct for multichannel. The 5.1ch audio was Audio3 in my example below.

The ffmpeg command line I generally use with fb2k for compressing, if I need to compress.
-i - -ignore_length true -af dynaudnorm=f=150 -c:a pcm_s24le %d

The scanner the R128Gain program uses is retarded slow compared to fb2k's scanner, and it only scans one file at a time, so I disabled true peak scanning for the last screenshot.

Before:




Converting:




After:




R128Gain agrees:


Last edited by hello_hello; 31st August 2018 at 18:59.
hello_hello is offline   Reply With Quote
Old 27th August 2018, 14:52   #6  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Perhaps WaveWizard can do what you require...
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:14.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.