Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an MKV file (vidui.mkv) with 6 tracks in it.

Track 1 - video - xvid - 1920x1080
Track 2 - video - xvid - 720x576
Track 3 - audio -  AAC - 1240kbps - English
Track 4 - audio -  AAC - 648kbps - Spanish
Track 5 - audio -  AAC - 648kbps - Commentary 1
Track 6 - audio -  AAC - 648kbps - Commentary 2

I want to convert the above file to a mp4 format with one h264 video and one AC3 audio. Also I want to convert track 1 (video) and track 5(audio).

If I use

ffmpeg.exe -i vidui.mkv -f mp4 -vcodec libx264 -acodec ac3 -crf 20 -sn -n vidui.mp4

it converts the first video track and first audio track, but what I would like it to do is convert track 1 and track 5.

share|improve this question

You can use the -map option (full documentation) to select specific input streams and map them to your output.

The most simple map syntax you can use is -map i:s, where i is the input file ID and s is the stream ID, both starting with 0. In your case, that means we select track 0 and 4:

ffmpeg -i vidui.mkv -c:v libx264 -c:a ac3 -crf 20 -map 0:0 -map 0:4 vidui.mp4

If you want to choose video, audio or subtitle tracks specifically, you can also use stream specifiers:

ffmpeg -i vidui.mkv -c:v libx264 -c:a ac3 -crf 20 -map 0:v:0 -map 0:a:1 vidui.mp4

Here, 0:v:0 is the first video stream and 0:a:1 is the second audio stream.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.