Hi,
I had to do some audio normalisation (loudness/RMS) on a batch of videos
recently. I used ffmpeg to automate the process but you have to be
careful what you're doing as you can overcook it.
I have a batch script that loops through a directory of video files
(changing it to apply to Rivendell wav files is just a case of adjusting
options).
First you analyse the file to get the peak and mean volumes:
ffmpeg -i file.wav -af "volumedetect" -f null /dev/null > /tmp/vol.tmp 2>&1
Then you grep that to read the mean and max volume lines:
MEAN="$(grep -E mean_volume /tmp/vol.tmp)"
MAX="$(grep -E max_volume /tmp/vol.tmp)"
A bit of clean up later and you get MEAN and MAX as just the numbers
(e.g. 7.7):
MEAN="$(echo ${MEAN##*:} | tr -d '[[:space:]]')"
MAX="$(echo ${MAX##*:} | tr -d '[[:space:]]')"
MEAN="$(echo ${MEAN:0:-2})" #Remove the db from the end e.g. 17db becomes 17
Next you do a quick calculation to figure out how much "gain" you need
to apply to adjust the average RMS volume. This is not the same as
adding +6 gain to everything like you would in peak normalisation.
ADJUSTMENT=$(echo "-13 - $MEAN" | bc) #-13dB RMS in this case is the
base line
In order for ffmpeg to work you need to format the adjustment like this:
FFMPEGVOL="volume=$ADJUSTMENT"
FFMPEGVOL="$FFMPEGVOL"dB
So it will read: volume=7dB (or whatever the calculation turned out to be)
ffmpeg -i file.wav -af "volume=$FFMPEGVOL" file.wav
FFMPEG should choose the same codec and settings from the original file
but you can always put them in manually to be safe.
Put all of this in a loop and you're done. You can run the output file
through the volume detect again to confirm the results.
This gave me a good baseline to work from but it might be too brash a
method if you're a particularly high end audio shop.
Regards,
Wayne
On 17/02/16 12:43, Cowboy wrote:
On Wednesday 17 February 2016 07:16:26 am ermina wrote:
either use peak normalization as before, or the
brand new loudness alignement. This way everyone is happy :)
On a practical basis i think it should work similar to the current peak
normalization on import : analyse file level and adjust to a default
global value (-23 LUFS) (either by destructively changing the level of
the file, or by adjusting cut gain).
I have no idea how technically it could be integrated
As previously, I can promise there will be a discussion.
Not today, probably not this week, but relatively soon.
_______________________________________________
Rivendell-dev mailing list
[email protected]
http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev