How To: transcode mkv to m4v w/o re-encoding

Random chit-chat and anything that doesn't belong elsewhere
Post Reply
jzietman
Enlightened
Posts: 146
Joined: Mon Feb 04, 2008 3:29 pm

How To: transcode mkv to m4v w/o re-encoding

Post by jzietman »

Ok, so this is a pretty hot topic on this forum and all over the internet; there are countless instances on forums of people wondering how to transcode their mkv files into mp4 or m4v without re-encoding the video and/or while preserving AC3 audio. Though complicated, I have come up with a functional method of doing this. The goals are to:
-Demux the mkv and remux the resulting files into an mp4 without re-encoding the video
-For the resulting mp4 to have an AC3 audio track
-For the resulting mp4 to also have a Dolby Prologic II stereo downmix of the AC3 track.
-In theory, subtitles could also be added, though I haven't tried.

This process should be both mac and windows friendly; the only mac-specific software I use is iMkvExtract, which has numerous windows equivalents. However, in my testing, I have found iMkvExtract to both more quickly and more reliably demux my mkv files and result in valid .h264 and .ac3 streams.

Windows software was run on Windows XP via Parallels 4.0.

Software used:
-iMkvExtract (Mac)
-Handbrake 0.9.3 (Mac)
-MP4Muxer 0.9.3 (Win)

1. Demux the mkv file into separate .h264 and .ac3 streams using iMkvExtract

Image

2. Open the original mkv file in Handbrake 0.9.3 and re-encode into the mkv container at very low video quality settings (use ff-mpeg for quickesti results) while setting the audio to re-encode the AC3 to Dolby Pro Logic II with AAC at 128 kbps or 160 kbps, whichever you prefer. The purpose of this step is to create the downmixed AC3 --> AAC track that we want in our final file. I have found no other reliable solution for this audio conversion than this admittedly roundabout and time-consuming fashion.

3. Again, use iMkvExtract, this time only extracting the AAC audio track.

4. Now, in MP4Muxer, add the three streams to the Multiplex list, select both 64-bit addressing and 64 times (if muxing a file larger than 4 GB), select the correct framerate for the video in the Frames/Sec drop-down menu, and set a destination. Under the "streaming" tab select "optimize." Hit Multiplex and you'll soon have a shiny new .mp4 file!

Image

This process is far from perfect. It requires me to use both native Mac programs and Windows programs via Parallels. It is time-consuming and roundabout. But, unlike every other method I have tried, it works, and it creates some beautiful .m4v files with h264, AC3, and AAC, just like the kind that HandBrake can encode from a DVD source (well, any source, technically).

Hope this answers some questions!

Edit: So far I haven't been able to get the resulting files to open in Quicktime, though they work beautifully in VLC. I'm trying to figure out what's going on now.
Edit 2: It was obvious. As the MP4Muxer GUI states, 64 Times kills QT compatibility. I'll try again without that option.
carbonunit
Posts: 1
Joined: Fri Dec 12, 2008 11:14 pm

Re: How To: transcode mkv to m4v w/o re-encoding

Post by carbonunit »

You can use Belight to transcode the ac3 file into an aac file that you can mux into your container. Been working well for me for a couple years now. Pretty simple user interface.
http://coreforge.org/projects/belight/

Also in order for them to work with quicktime you want to make the extension .m4v as well as turning off all the 64bit stuff when muxing with MP4 Multiplexer.

Also I would like to know if these files work in AppleTV. If they don't then this won't work for me. The profile of most of these mkv h264 files is 5.1 high profile. I need them to be 3.0 low profile to work in appleTV. HMMMM... So many variables in the encoding world my head could explode! :D
Post Reply