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, but my target is different from yours: movies would involve splitting and recombining the audio and video streams. My process converts anything that ffmpeg will play into WAV files (CD format), which sox then concatenates and compands into another WAV file, which lame then encodes to an MP3. My target is to convert (possibly segue'd) classical music tracks (potentially huge dynamic range) into something that can be listened to on an MP3 player in noisy places like, say, the street. 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. ($Unique0 is just a nonce working directory.) > or can it be done automatically, on the fly? On the fly would mean delaying the video to match the audio, which is necessarily delayed (by sox needing look-ahead in the audio stream). I've thought about it over the years, but never tried it, mainly because in the situation where it would have been most useful (ie driving, particularly commuting alone), I didn't have any way of intercepting the audio between tuner and amplifier. (Nowadays, I rely on the thumb control on the steering wheel.) That's for the radio, and occasional CD. Otherwise, the tracks on my USB stick would usually have been companded as above. 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.) Cheers, David.