I'm in need of a way to re-encoding MKV unproccessed (via Pass Through)...

I pretty much found the solution (see source at the bottom) but I need a little bit of help. As what kind of script do I have to save the script? Anybody willing to help out here or maybe compile the app?

Idea 1:

  1. Use tsMuxer to extract the video stream and the audio track(s) into separate files.
  2. Reencode the audio track into AAC with afconvert (comes with OS X, looking at the man page it supports most 2ch and 5.1ch formats)
  3. Use mp4box to mux the video and audio into a single MP4 file. posted by wongcorgi at 10:34 PM on October 6, 2009

Idea 2:

mencoder -o <new file name> -oac copy -ovc copy -of lavf -lavfopts format=mp4 <old file name>

To make the snippet above into an Drag and Drop application one could use this program: http://www.advogato.org/proj/DropScript/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Source: http://ask.metafilter.com/134805/I-need-an-automated-way-to-convert-MKV-to-MP4-on-Mac-OS-X


Does it need to be a script? Would HandBrake work instead?


If it does need to be a script, I've had better success with ffmpeg than with mencoder, although I haven't regularly converted mkv files to mp4.

Your mencoder command does not work for me; QuickTime cannot open the resulting mp4 file. Here's a lengthy article about converting an mkv file into an iTunes-compatible mp4/m4v file. Another article lists where to get some of those tools for your Mac.

The basic process is:

  1. Use mkvinfo to figure out framerate of source mkv file.
  2. Use mkvextract to separate video and audio streams into .h264 and .ac3 files, respectively.
  3. Use hexedit to change the first line of the resulting .h264 file.
  4. Use ffmpeg to convert the .ac3 file to a .m4a file.
  5. Use MP4Box to add the .h264 and .m4a files to a new .mp4 container with the framerate that you gathered in step 1.

There's a thread about converting mkv to mp4 for PS3 viewing, which leads to a post with a script. Haven't tried it myself but it seems to use mkvextract and ffmpeg so it may do pass-through. Uses Python.

  • HandBrake doesn't seem to allow pass-through, which would be more efficient, as you state in your question. – fideli Feb 8 '10 at 22:02
  • 1
    Btw if you really want to script this transcoding you can install the handbrake with no GUI and using command line only – Kami Feb 8 '10 at 23:33
  • Thanks for the articles fideli. Sadly Handbrake doesn't do the pass-through, like you already stated in the above comment. Otherwise it would be a very fine choice since it's capable of adding subtitles and audio tracks in a user friendly manner. __________________________________________________________ The thing is I just want something (script, automation, app, whatever) that allows me take my MKV's and convert them in a single process, since I do this quite often. I own MKVTools but it's yet not batch compatible and also one can't adjust the audio conversion. – pattulus Feb 10 '10 at 12:16
  • @patte: I've edited the post to include a link to a script that might work. – fideli Feb 10 '10 at 21:18

At the moment my tool of choice is MP4Tools, the MKVTools successor. It handles batch conversion of MKV files pretty neatly and does an overall good job.

Link to MP4Tools: http://www.emmgunn.com/mp4tools/mp4toolshome.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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