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.

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

Explanation: this command finds all .mkv files and converts the first audiostream to ac3 with a bitrate 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.

Cover image by Adi Goldstein