ffmpeg : Only keep one language audio track

When downloading movies from the internet, you may notice that some titles include the word “MULTI.” This indicates that the file contains multiple language options.
However, despite the relatively low cost of disk space nowadays, I prefer not to store unnecessary audio tracks that I will never listen to.

That is when the invaluable program named ffmpeg come to the rescue to eliminate these useless tracks.

You can use the following FFmpeg command to keep only the English audio track and copy the rest of the tracks into an MKV file:

ffmpeg -i “in.mkv” -max_muxing_queue_size 1024 -map 0:v -c:v copy -map 0:a:m:language:en -c:a copy -map 0:s? -c:s copy "out.mkv"

Here’s a breakdown of what each part of the command does:

ffmpeg: This is the command that starts the FFmpeg program.
-i “in.mkv”: This specifies the input file, “in.mkv”, that FFmpeg will be working with.
-max_muxing_queue_size 1024: usefull because sometime ffmpeg crash when this is not present.
-map 0:v: This selects the video stream from the input file (stream 0) to include in the output file.
-c:v copy: This copies the video stream from the input file to the output file without any encoding or re-encoding.
-map 0:a:m:language:en: This selects the audio stream from the input file (stream 0), but only if it has the “en” language code. This is useful if there are multiple audio tracks in the input file and you only want to include the English track in the output file.
-c:a copy: This copies the selected audio stream from the input file to the output file without any encoding or re-encoding.
-map 0:s?: This selects any subtitle streams from the input file (stream 0), if they exist. The ? makes the subtitle stream optional, so if there are no subtitles in the input file, this won’t cause an error.
-c:s copy: This copies any selected subtitle streams from the input file to the output file without any encoding or re-encoding.
“out.mkv”: This specifies the output file that FFmpeg will create, “out.mkv”.

There are many language codes available in FFmpeg for selecting audio and subtitle streams based on language. Here are some examples:

English: en
Spanish: es
French: fr
German: de
Italian: it
Portuguese: pt
Russian: ru
Arabic: ar
Chinese: zh
Japanese: ja
Korean: ko
Hindi: hi
Urdu: ur

Leave a Comment

Your email address will not be published. Required fields are marked *