Skip to content

Batch convert mkv audio to AC3 with ffmpeg

Published: January 18th, 2023 | Updated: January 30th, 2024 Ubuntu Video Audio An audiomixer seen from the front

Step 1

Go to the directory where your files are.

Step 2

Make sure ffmpeg is installed.

Step 3

Use the following command to process the files.

localhost ~$ for x in *.mkv; do ffmpeg -i "$x" -map 0:v -map 0:a:0 -map 0:s -c copy -c:a ac3 -b:a 640k "ac3-$x"; done
shell

Explanation: this command finds all .mkv files in the current directory and converts the first audio stream to ac3 with a bit rate of 640k. The files are renamed with an “ac3-” prefix, so you can compare the result.

Step 4

Remove the old files after you have checked if the audio is still correct and synced to the video. Enjoy your video files.

About Marcel Bootsman

Marcel discovered the web in 1995. Since then he has paid attention to and worked with lots of technologies and founded his own WordPress oriented business nostromo.nl in 2009.

Currently Marcel is Business Development Manager Dutch & DACH Markets at Kinsta where he helps Kinsta's client base grow with Managed WordPress, Application, Database and Static site hosting.

You can contact Marcel on a diverse range of online platforms. Please see the Connect section on the homepage for the details.