I found this thread: Handbrake settings to convert MKV to MP4 while retaining the original quality

And I can "convert" .MKV to .MP4 with the following code:

for %%a in ("*.mkv") do D:\Programme\Converter\ffmpeg\bin\ffmpeg.exe -i "%%a" -c:v copy -c:a copy "%%~na .mp4"

The only problem is, that there are 2 audio lanes. The german, and the english. With the code above, it only copies the german (1st) language. But not the 2nd audio language. How can I do that?

At the moment I just convert from .MKV to .MP4 with german lang only. But I want to be able to switch the language with my VLC player from german to english.

Thanks for your help!

EDIT: I found that thread here: http://ffmpeg.gusari.org/viewtopic.php?f=25&t=611

And I tested with that informations. I changed my code above, to this code:

for %%a in ("*.mkv") do D:\Programme\Converter\ffmpeg\bin\ffmpeg.exe -i "%%a" -map 0:0 -map 0:1 -map 0:2 -c:v copy -c:a:0 copy -c:a:1 copy "%%~na.mp4"

Did I do something wrong here? How could I add the german / english subtitles to that? IF I would add a subtitle map thing there, and my .MKV have no subtitles at all, would this be a problem? I just want to create a .bat file which converts a .MKV with 2 soundtracks and 2 subtitles. So that I can "remux" (or convert dunno) all my .MKV files to .MP4 without losing any informations.

At the moment, my .MKV have no subtitles, so it's not important. But it's better to prepare for the future, right?

So please tell me if I did it right, and perhaps how to add the subtitles too. It's the first time I ever used FFmpeg. Just downloaded it, never heared about it. Never really used the CMD for that.

  • You should show an actual, unscripted example command and the complete console output. The problem is that Matroska supports many more video, audio, subtitle, and data formats than MP4. If you want to stream copy (re-mux) from MKV to MP4, then you have to make sure that the output can support the various formats, and/or re-encode ones that are not compatible. Also, MP4 support for subtitles sucks.
    – llogan
    Apr 19, 2015 at 0:06
  • I could copy paste the whole CMD if it helps. Well I really don't need to get the subtitles. I just want to change the .MKV to .MP4 with ALL the audio lanes (soundtracks). With that code it worked. I have german and english voice. But do I have to adjust that manually each time? So when a file have 3 audio lanes, do I need to adjust it each time :-\ :-( ?? Here is the full log: pastie.org/private/9lqyvhyotnh1o4gp6rg5g Apr 19, 2015 at 0:16
  • I just need to know, if that code is correct. I mean it works 100% well. I get the same file size, the same quality (compared it, should be the same) and I got both audio lanes. German and English. So normally I could start converting my 400 files... My Sony EX725 can't play .MKV but my new Sony 905A can. So I just try to convert all the .MKV to .MP4 for the old Sony TV. Apr 19, 2015 at 0:24
  • [mp4 @ 00000000002fb3a0] Codec for stream 0 does not use global headers but cont ainer format requires global headers [mp4 @ 00000000002fb3a0] Codec for stream 1 does not use global headers but cont ainer format requires global headers [mp4 @ 00000000002fb3a0] Codec for stream 2 does not use global headers but cont ainer format requires global headers [mp4 @ 00000000002fb3a0] track 1: codec frame size is not set [mp4 @ 00000000002fb3a0] track 2: codec frame size is not set That's an error I get. But the file works. Can watch it, can change the audio, same quality... hmm Apr 19, 2015 at 2:05
  • A one run script won't work here, because you don't know the number and order or streams. What you need is to sort movies in 1vid1aud1sub and 1vid2aud2sub or other variations, and only then you can use -map and a corresponding -c: copy. For subtitles you have -c:s. Those error's might be related to how MKV stores codec specs in its own container while MP4 differs. If it's working, don't try to fix it.
    – JasonXA
    Apr 19, 2015 at 22:04

3 Answers 3


ffmpeg does not automatically map all tracks; default stream selection will only map one audio, one video, and one subtitle track to the output. If you want to map all streams, use -map 0. If you want to be able to select what to map, you'll have to parse the input file first (ffmpeg -i input.mkv) and use some scripting to construct the final conversion command. ffprobe can be helpful for that. See FFmpeg Wiki: FFprobe Tips for examples.

You can specify -c copy to stream copy all streams, no matter what type they are. You can also index video and audio streams separately, so your command can be shortened to:

ffmpeg -i input.mkv -c copy -map 0 output.mp4
  • Thx for your response! My final script was for %%a in ("*.mkv") do D:\Programme\Converter\ffmpeg\bin\ffmpeg.exe -i "%%a" -c:v copy -c:a copy "%%~na.mp4" pause and it worked. I got german and english sound, and the same video quality / size. BUT I got an error message! Even with that error message, it still works. Even on the Sony TV via USB. See the error message in a comment above! :-) Do you know what the error means? I google it, And got no answer. Apr 20, 2015 at 14:23
  • Can you upload a full command-line log somewhere and leave me a comment? (e.g. pastebin.com)
    – slhck
    Apr 20, 2015 at 15:20
  • I already did: pastie.org/private/9lqyvhyotnh1o4gp6rg5g (in a post above). That's the whole log i got from the CMD. It's my first time using FFmpeg. Well, it worked. I have the same image quality, german and english sound. And the same file size like the .MKV have. And it works for my Sony TV. The Sony TV can't play .MKV (the old TV), but can play .MP4 Apr 21, 2015 at 23:33

There is an open source program called VCT: https://sourceforge.net/projects/videoconvertertranscoder/?source=directory

It's a GUI for ffmpeg. You can also edit ffmpeg command manually. It has a tab called Transcode where you can repack MKV to MP4, but this tab has no options to add subtitle.

If you want to repack MKV to MP4 and add subtitles at the same time here is the procedure:

  1. Go to Convert tab and select your Input File
  2. In Video container select copy and in Audio codec also select copy
  3. Click add subtitle and select your external SRT file
  4. In the ffmpeg command text box replace the subtitle part -c:s srt "" with -c:s mov_text ""
  5. click Add to batch list and then click Start Encoding will be done in a minute or two.

Of course, if you don't mind encoding twice, and you don't like typing commands, you could also do it like this:

  1. select tab Transcode and drag your file onto Input file.., click Start, it will be done within a minute.
  2. Then, select newly encoded MP4 and in Video container select copy and in Audio codec click copy.
  3. Click Add to batch list and then click Start. Encoding will be done within a minute.

screenshot of doing the requested encoding MKV to MP4


Well, I'm using a .bat file like this:

for %%a in ("*.mkv") do D:\Programme\Converter\ffmpeg\bin\ffmpeg.exe -i "%%a" -c:v copy -c:a copy "%%~na.mp4" 

But I get an error message, but the .MP4 still works fine. Here a log file: pastie.org/private/9lqyvhyotnh1o4gp6rg5g

The Problem is that my old sony TV sometimes freeze while watching the .MP4 I can't tell you if it's just the "player" from the TV or the converted file itself. The GUI seems good. But if you want to convert like 20 files in a row it's a lot of clicking. The .bat file just do that automatically with all those files in one folder.

Perhaps someone knows why I get an error message, and if this script is wrong or not :)

  • I would recommend that you remove the secondary question in your answer and ask it as a new question referencing this one. Other than that your answer is quite good.
    – Burgi
    May 27, 2016 at 7:28

You must log in to answer this question.

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