3

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"
pause

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"
pause

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.

3 Answers3

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
llogan
  • 63,280
slhck
  • 235,242
0

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

dotokija
  • 126
0

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 :)