Re-encoding batch of videos with boosted audio - how to automate?

TLDR: I’m trying to automate the following process - and thanks in advance to anyone who wants to share some ideas / suggestions :slight_smile:

“hey Software X - please re-encode all the files in folder path X/Y/Z, keep the same video track but add +9dB to the audio track, and save them all as “original name - louder” in folder /P/Q/R”

Not TLDR: In the last 2 months I recorded 40 videos of Physics lectures for my University job.

Because I’m a dummy, I exported them all with very quiet volume levels.

I’m looking for an automated method to re-encode them all in one go, with - say - a +9dB volume boost of the audio track but no modifications to the video track. I think it can be done with ffmpeg and some smart command lines but I’m not the best at that sort of thing.

I know how to do it by hand with Avidemux - but that requires me loading / editing / re-exporting each video separately.

Not the most elegant solution, but if you are a python guy you could probably do with pyautogui.
https://automatetheboringstuff.com/2e/chapter20/

1 Like

(That’s what graduate students are for! :rofl:)

1 Like

Looks like Handbrake could do that:

There’s a “Gain” box where you can input anything from -20 to +20.

Handbrake seems to have a robust batch processing system, but I haven’t used that myself yet.

2 Likes

Cool cool cool thank you all :slight_smile:

1 Like

Good point. I hadn’t thought of Handbrake. I’ve done batches on Handbrake many times for format conversion. Works great and easy to use.

3 Likes

Thanks again everyone for the input :slight_smile:

I found the solution! The following lines of code work on Windows 10, after having installed ffmpeg. The video track gets copied with no modifications - so that saves a lot of computer time, while a filter (boost or normalisation) gets applied to the audio track.

I put all the videos in the same folder then navigated there with the command line (I also made two subfoldes called “louder” and “normalised”)

This code normalises all the videos and puts them in the appropriate subfolder (settings copypasted from a YT tutorial I found):

for %a in (*.mkv) do ffmpeg -i "%a" -af loudnorm=I=-16:LRA=11:TP=-1.5 -c:v copy -c:a aac -b:a 128k "normalised/%~na_nomalised.mkv"

This code does the same thing but with a +18dB volume boost instead (my videos were very quiet!)

for %a in (*.mkv) do ffmpeg -i "%a" -af "volume=18dB" -c:v copy -c:a aac -b:a 192k "louder/%~na_louder.mkv"
3 Likes

That’s a true wizard solution :ok_hand:

1 Like