Easy way to auto-batch Matroska (mkv) files to MP4 container?

Oct 4, 2004
10,515
6
81
I have a ton of movies all in Matroska containers. All of them are H.264 MPEG-4 Part 10/AVC (using the x264 encoder) video files with variety of audio formats (AC3/DTS/AAC/MP3) and all of them include subtitles in the SRT format. Some but not all have chapters for easy navigation.

Is there any tool that would let me convert the mkv files to mp4? I probably shouldn't say convert. What I really mean is demux all the streams (audio/video/chapters/subtitles) and mux them all back into a mp4 container? I'm not too concerned about retaining the chapter information but that would be nice too. Also, can I automate the whole process and create a batch job?

I tried searching for this but all I get are random links to shareware applications that don't do this and discussions on other forums that didn't yield results.

And for those wondering why, just for some compatibility reasons with certain portable media players that don't like to play well with Matroska containers.
 
Oct 4, 2004
10,515
6
81
Found something that works! Not the best title but it's called mkv avi to mp4 for iPad and does what I need it for. Just had to change the default settings - by default, it attempts to downmix 6-channel audio tracks to stereo and changes the AVC level flag to 3.1 (if higher).

Once that's been taken care of, it works fine. Have done a few conversions so far and no issues yet with audio/video or subtitle sync.

Edit: LOL, I spoke too soon. I just realized by looking at the logs and confirming with other tools that the software is encoding AC-3 audio to AAC. Interestingly, one 448kbps AC-3 audio track (for 21 Grams) ended up with a 576kbps variable bitrate AAC track. I need to find a file with a DTS track and check what it does with those. I suppose it's doing this for iPad/iPhone compatibility.
 
Last edited:

TSDible

Golden Member
Nov 4, 1999
1,697
0
76
Have you tried handbrake?

http://handbrake.fr/

I use it to encode all my video files. It has a wide array of custom settings, but I just use one of the built in ones.

It is GPL open source software, so there is no reason not to try it.

:)
 
Oct 4, 2004
10,515
6
81
I did but it tries to re-encode the files. No simple option to simply copy the original streams into a new container.
 

smitbret

Diamond Member
Jul 27, 2006
3,382
17
81
mkv2vob will batch convert. The program creates files that are optimized for the PS3, and puts them in an .mpg package, but I would think that .mp4 capable shouldn't have any trouble with .mpg.

Your other option would be to batchdemux with tsmuxer (could be troublesome if the streams have the same names, though) and then remux with MeGUI.
 
Last edited:

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
This can't be done as a simple container conversion:

The mp4 container is very limited as to the type of streams it can carry. While pedants will point out that, technically, any type of stream can be carried as proprietary data, very few are officially specified. (And even of those stream types officially supported, even fewer of them are actually supported by most playback software).

MPEG-4 Part 10/AVC video (and older MPEG 4 video) is universally supported
AAC audio is also universally supported.

While technically MP3 audio, and a variety of other audio formats are usable - I've not come across any software that actually supports them. DTS and AC3 are not supported at all, as far as I can tell. All conversion software that I'm aware of will downmix then encode as AAC.

There is also very patchy support for subtitle playback - while text-based subtitles are in the spec for MP4, I'm not aware of anything that actually plays them - as a result, most conversion software will hardcode subtitles when re-encoding the video.
 
Oct 4, 2004
10,515
6
81
Thanks for the responses. Can't believe I missed freedomsbeat's thread. Fayd's response is actually what I initially thought I would need to do (spend some time learning command-line options) but I was too lazy for that.

Mark, thanks for clearing up some confusion I had over AC3/DTS in MP4. I realize now that while technically possible, it probably wouldn't be a good idea to try and do that for the sake of universal compatibility.

Once again, thanks guys, I will try and figure out those command line switches better. Another question: anyone know a tool that would let me point it to a folder with a bunch of videos and display a nice table featuring container type, video stream type, audio stream type, bitrate and other information of interest?

I know it sounds specific but I have never come across such a tool. Most tools let you open a file and check the stream information but I wish I could just list them all in a column and check relevant information in the same row - sort of like the Details view in Windows, only with videos.