I've been trying to remove unneeded audio streams from an MKV (Matroska) file. The reason why I want to do this is to avoid having to manually select the wanted stream in Windows Media Player.

The input file gives the following ffmpeg info:

Stream #0.0: Video: mpeg4, yuv420p, 704x396 [PAR 1:1 DAR 16:9], 29.98 tbr, 1k tbn, 29.98 tbc
Stream #0.1(eng): Audio: aac, 24000 Hz, 5.1, s16
Stream #0.2(jpn): Audio: aac, 24000 Hz, 5.1, s16
Stream #0.3(eng): Subtitle: 0x0000
Stream #0.4(eng): Subtitle: 0x0000
Stream #0.5: Attachment: 0x0000
Stream #0.6: Attachment: 0x0000

Since I want streams 0, 1 and 3 (sub), my ffmpeg command looks like this:

ffmpeg -i input.mkv -map 0:0 -map 0:1 -map 0:3 -vcodec copy -acodec libmp3lame -newsubtitle test.mkv

which strangely gives the error:

At least one output file must be specified

Removing the subtitles:

ffmpeg -i input.mkv -map 0:0 -map 0:1 -vcodec copy -acodec libmp3lame test.mkv

gives me this:

Number of stream maps must match number of output streams

I seems I don't really understand how the "map" option works. Would someone help me figure it out?

  • For anyone needing to automate this, I've done this: find ./ -maxdepth 1 -type f -exec mkvmerge -o ./output/"{}" --audio-tracks 2 --video-tracks 0 --subtitle-tracks 5 --default-track-flag 2 --default-track-fla g 5 --forced-display-flag 5 "{}" \;. This finds all files in current directory, include only audio track 2 video track 0, and subtitle track 5. Also makes track 5 default subtitle and forces it. Then save each file in ./output directoy.
    – Hache_raw
    May 6, 2022 at 12:28

4 Answers 4


If all you want to do is remove a stream, not re-encode, you probably want to do this with the MKVtoolnix package (see videohelp.com's page).

There are a couple of GUIs that may help you (check around on the videohelp link). I'm not sure what the exact mkvmerge commandline might be, but I think something like this would work:

# first, get audio track info so we know which one to keep
mkvmerge -i input.mkv
File 'input.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AAC)
Track ID 3: audio (A_AAC)        <----------- for example, let's keep this one
Track ID 4: audio (A_AAC)

mkvmerge -o output.mkv --audio-tracks 3 input.mkv

That should do the trick (I don't have a file handy for testing, sorry). The --audio-tracks option tells mkvmerge to copy only the listed audio tracks to the new file. If you wanted to keep 2 & 3 but not 4, you could use --audio-tracks 2,3.

mkvmerge has a lot of other options for setting titles, adding a delay to sync audio, etc, so check the manpage for details.

  • 5
    Looks like --atracks option does not exist anymore, instead one should use either --audio-tracks or --video-tracks.
    – malat
    Jan 31, 2015 at 13:15

Try -f to force the specified format:

ffmpeg -i input.mkv -map 0:0 -map 0:1 -map 0:3 -vcodec copy -acodec libmp3lame -newsubtitle -f mkv test.mkv
  • This strangely gives me the error: "At least one output file must be specified" Dec 1, 2009 at 21:44
  • try using a full path, ie: C:\path\to\output.mkv (I assume you're on windows by the media player reference)
    – user1931
    Dec 1, 2009 at 22:02
  • @John T: using the full path (with or without quotes) still gives me the "At least one output file must be specified" error message. Dec 2, 2009 at 21:46

There are really two separate issues here:

  1. In the first command line, the order of parameters may be wrong. I think the -newaudio switch needs to be at the end, after the output file name.

  2. The second command line, "Removing the subtitles", since the input file has subtitles, you need to use the -sn switch to remove them. Otherwise, it seems FFmpeg wants at least one specified in the -map list.


In your first command, you didn't specify that test.mkv was your output file. Looks like you need to change that part to be something like ... -c copy test.mkv or specify the codec like ... -c:s copy test.mkv.

And not sure what that -newsubtitle flag is doing in there. But if you have a subtitles file you want to add in, you should be able to do another input flag -i input.srt. See this link for that.

In your second command, I think it looks like you are trying to map the video stream and trying to copy it. So you might want to try removing the -vcodec copy instruction and it should just work. :)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .