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

Re: normalize audio in mp4s



Quoting David Wright (2020-03-09 04:15:41)
> On Sat 07 Mar 2020 at 12:12:18 (+0100), Jonas Smedegaard wrote:
> > Quoting David Wright (2020-03-07 04:56:05)
> > > On Fri 06 Mar 2020 at 20:33:48 (+0100), Emanuel Berg wrote:
> > > > how can I normalize the audio in mp4 video files? both WRT not 
> > > > having to lower the volume when there's a firefight and raise it 
> > > > when they start talking again, _and_ WRT playing several files, 
> > > > e.g. music videos, and having them have basically the same 
> > > > volume?
> > > > 
> > > > if need be, I can set volume modifications to each file, 
> > > > manually if I knew how to do it. this wouldn't work for 
> > > > firefight/talk movies tho.
> > > 
> > > I use the compand and gain effects in sox,
> > [...]
> > > The critical lines (embedded in a load of shell) are
> > >   ffmpeg -hide_banner -y -i "$1" -ar 44100 -ac 2 "$Unique0/$Filenumber.wav"
> > > where the $Filenumbers are 10000+ sequence numbers so they collate,
> > >   sox "$Unique0"/1*.wav -t wav -r 44100 -b 16 -c 2 "$Unique0/0.wav" compand 0.3,1 6:-70,-60,-20 -15 -90 0.2 gain -n -0.01;
> > > where the companding parameters are reasonably aggressive and the
> > > normalisation is "turned up to ten", and
> > >   lame -b "${Fixedbitrate:-128}" "$Unique0/0.wav" "$Unique0/0.mp3"
> > > is for fairly unendowed MP3 players.
> > [...]
> > > I would be interested if someone worked out how to do splitting, sox, 
> > > and recombining reliably enough to preserve the synchronisation. 
> > > (Automatic, but not on the fly.)
> > 
> > ffmpeg should be able to do the whole processing, if you want peak 
> > or RMS normalization.  If you want EBU R128 normalization then you 
> > need e.g. melt (which uses ffmpeg internally and adds aditional 
> > plugins).
> > 
> > Here is a good explanation on the difference between "peak", "RMS", 
> > and "EBU R-128": https://www.learndigitalaudio.com/normalize-audio
> > 
> > Hhere are some example of using ffmpeg: 
> > https://superuser.com/questions/323119/how-can-i-normalize-audio-using-ffmpeg
> 
> I don't think normalisation, on its own, would be of much help to me.
> Many digital recordings are mixed for perfect listening conditions,
> and that's often just not possible, so some degree of dynamic range
> compression is necessary *within* each track. And where the tracks
> segue on a CD, that necessitates concatenation, as least with my
> technique, making for longer tracks.

Agreed, you need more than (strictly speaking) normalization alone.

When OP wrote "how can I normalize" I read it to more casually imply 
possibly more parts than (striclty speaking) normalization alone.

That's why I wrote "the whole processing" above.

sox can (compress and) normalize audio.

ffmpeg can do (almost) same as sox, also embedded in video.

melt can do (almost) same as ffmpeg, and can do some parts better.


> I don't know whether/how movies are segmented (I've seen reference to 
> "chapters" but don't know what they are). But it sounds as if the OP 
> needs similar DR compression between or even within scenes.

Just like audio-in-music can be high dynamic range (one tune a flute 
solo, another an orchestra), so can audio-in-movie (one scene the sounds 
of bed sheets, another a car explosion): Audio is audio, it is dynamic.

Both audio-in-music and audio-in-movie can to change dynamic range per 
tune/scene or within them.  Depends on how it was composed, performed, 
recorded, and mixed.

Both audio-in-music and audio-in-movice can already be compressed.  
Depends on how it was mastered (i.e. post-processed).



The OP asked about 
normalization of audio, including audio embedded in video.


> > I use melt because I can then handle video as well - either do 
> > various compression of that as well, or "just" pass-through (which 
> > still involves the challenge of keeping audio and video in sync - 
> > which is more or less reliable depending on the container format of 
> > each video).
> 
> I'm not sure what type of video compression you mean: file size or 
> something else? We have one TV which can darken dark scenes and 
> brighten bright ones. Perhaps you need the opposite for watching 
> movies in the back seats of a car?

I meant file size.  Yes, not only dynamic range of audio but also color 
spaces can be compressed, but please let's limit this conversation to 
_audio_ processing (I mentioned video processing only because my script 
happens to handle more than audio (compression and) normalization).

I did not sugggest melt for its ability to also normalize video.

I suggested melt for its ability to...:

 a) extract+recompress compressed audio formats
 b) decouple+realign audio intertwined with video in multimedia file
 c) do professional grade _audio_ normalization (EBU R-128)


> Melts looks like a very professional editor, but doesn't appear to be 
> easy to configure for automatic processing, so it might not suit my 
> requirements.

If you only process uncompressed audio then sox is fine.

The OP explicitly ask about processing audio embedded in multimedia, 
where sox is not suitable: You need a tool that can not only extract 
audio but also stitch it back together while keeping audio and video 
tracks in sync.  You therefore need ffmpeg or something based on it.

Melt is based on ffmpeg and adds a high quality audio normalizer.

Melt is indeed not as easy to use as ffmpeg, however: Ffmpeg is 
optimized for scripting where the backend of melt (MLT framework) is 
primarily used in GUI applications, secondly in the text-based tool melt 
interactively, and only thirdly scripted with melt.

So if high-quality normalization is not important (and you don't want to 
try play with stripping my script), then directly use ffmpeg, or use any 
other of the many many many ffmpeg-based tools available.

...or use sox (but still use ffmpeg to extract audio part of mp4 files).


 - Jonas

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private

Attachment: signature.asc
Description: signature


Reply to: