[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: normalize audio in mp4s



On Thu 12 Mar 2020 at 02:38:28 (+0100), Emanuel Berg wrote:
> Reco wrote:
> 
> >>> Personally I just reencode audio in such cases.
> >>> For instance (0:1 is the first audio track, use 0:2 for
> >>> english):
> >>> 
> >>> ffmpeg -i ford-v-ferrari-2019.mkv -map 0:0 -map 0:1 \
> >>> -c:v copy \ -c:a libopus -b:a 128k -ac 2 -clev 1.414
> >>> -slev .5 \ ford-v-ferrari-2019.good_audio.mkv
> >>
> >> That's a useful little recipe, and pleased the OP, but can
> >> you just clarify the arguments -clev 1.414 -slev .5
> >
> > Sure. First things first - [1]. clev stands for
> > center_mix_level, slev for surround_mix_level. Both values
> > are dB.
> 
> Thanks for the details!
> 
> This command, it solves the 5.1/surround -> stereo issue,
> right? That's the -map, -c:a, -b:a, and -ac 2 things.

My understanding is that -map 0:0 -map 0:1 asks for the video and the
portuguese respectively, -c:v copy asks to copy the video (v),
-c:a libopus asks for the opus audio encoder, -b:a 128k is
128k bits/sec audio, -ac 2 is two channels of audio (a).

> But later on ...
> 
> > What ffmpeg does by default then downmixing is:
> >
> > FL = FL + 0.707 * FC + 0.707 * BL
> >
> > where FL stands for Front Left channel, FC is Center, BL is
> > Back Left channel. And it's the same for right channel.
> >
> > Your typical movie has dialogue on center channel, gunfire
> > & cars' sounds come from the front channels, ambient comes
> > from the back ones.
> 
> ... namely _here_, it "sounds" like you are addressing the
> other issue?
> 
> With the -clev and -slev?
> 
> 1.414 because of 2*0.707 ?
> 
> Neither -clev nor slev are in the ffmpeg(1) man page BTW -
> and that page is 2419 lines!

You need to install ffmpeg-doc and then point your browser (Ctrl-O
typically) at file:///usr/share/doc/ffmpeg/manual/ffmpeg-all.html
which is a little less than 30000 lines!

These arguments still worry me. I *think* the resampler is being used,
§28 on that page, and I would expect to see -clev 3 and -slev -3 in
order to increase the centre and decrease the surround by 3 dB each
(which is doubling/halving the power IIRC). ¹

You could test this by using some more extreme values (up to ±32,
which should cut one out altogether) to make sure you hear the
effect.

> But OK, I can use 'ffprobe -hide_banner 2>&1 $1 | grep -i
> audio' and then it should say stereo and not 5.1, gotcha...
> 
> The other problem I can detect myself by (not) hearing...
> 
> Are there anything else you routinely look for and correct?

On Thu 12 Mar 2020 at 02:52:31 (+0100), Emanuel Berg wrote:
> Reco wrote:
> 
> > Your typical movie has dialogue on center channel, gunfire
> > & cars' sounds come from the front channels, ambient comes
> > from the back ones.
> >
> > So, what's needed is to gain volume on dialogues
> 
> OK, so that's
> 
>   -clev 1.414
> 
> since dialog comes from the center.
> 
> > while downplaying ambient somewhat.
> 
> Is surround (-slev 0.5) front _and_ back? Or just back, as
> ambient comes from the back? From your description above, it
> sounds like one should decrease the front level? But perhaps
> this is done as well?

AIUI the surround channels are at the back. Just having clev and slev
makes it a little unclear. I suppose it's possible that the front
L/R channels stay at 0dB while you increase clev and decrease slev,
and if you want the front L/R channels decreased, you've just got to
do it by increasing clev some more. I'm guessing here.

On Thu 12 Mar 2020 at 03:07:23 (+0100), Emanuel Berg wrote:
> Reco wrote:
> 
> > FL = FL + 0.707 * FC + 0.707 * BL
> 
> With mediainfo(1) as recommended by Mr. Smedegaard, I got
> this
> 
> $ mediainfo ford-v-ferrari-2019.mkv | grep -i channel
> Channel(s)                               : 6 channels
> Channel layout                           : L R C LFE Ls Rs
> Channel(s)                               : 6 channels
> Channel layout                           : L R C LFE Ls Rs
> 
> L = left, R = right, C = center?

Yes, all at or near the front.

> LEF = low-frequency effects? [1]
> 
> Ls, Rs = left and right subwoofers?
> 
> 
> [1] https://en.wikipedia.org/wiki/Low-frequency_effects

Ls, Rs are the surround channels, LFE is the sub-woofer. You only need
one of the latter because you can't locate it with your ears at this
frequency.

https://en.wikipedia.org/wiki/5.1_surround_sound

¹ Confusingly, the downmix levels at §15.2.1.2 are specified as levels
  rather than dB. Perhaps this is because they want to be able to have
  0 as a possible option, which would be -∞dB.

Cheers,
David.


Reply to: