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.

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.