Our thinking


Quick MKV to MP4 conversion without transcoding

I’ve got a number of videos in Matroska MKV format that I want to play on my PS3. The video in the MKV container is MP4, so the PS3 can handle it, but it doesn’t like the container format – it wants an AVI or MP4.

There are lots of ways you can get from one format to the other, my main requirement is to do container conversion where possible and leave the data stream untouched. This isn’t 100% possible when going from MKV to MP4 as most MKV files I’ve encountered, whilst they may have h.264 or MP4 video, they generally have an AC3 (Dolby Digital) sound track. It seems that MP4 files need to have an AAC sound track instead.

Therefore, the objective is to convert from one audio format to the other whilst leaving the video stream as-is. Of all the software out there that will assist with this task, it seems that just two easily available programs are needed.

First up, you must have Perian installed. Even if you’re not doing video conversions, Perian is so useful that you need it anyway.

Next, you need QuickTime Pro. I haven’t tried this using QuickTime X on Snow Leopard, so I don’t know if this removes the need to pay for the QuickTime Pro upgrade.

Once you have Perian installed, open the MKV video in QuickTime Player. This will take a fair amount of time, depending on the size of the video, as when opening an MKV in QuickTime Player, it reads the whole file in.

At this point it is trivial to convert this to a QuickTime MOV file which is close to, but not quite, an MP4 file. Simply go to File -> Save As… and make it a self-contained movie. Done.

If you want to make it an MP4, a little more work is required. Go to File -> Export and select Export: Movie to MP4. Hit the Options button and under the Video tab, select Video Format: Pass through. Under Audio, you may want to up the bitrate on the audio. Hit OK and then Save and the video will be exported using the selected settings. On my machine with a 2.8GHz CPU, exporting a 1.4GB video only took a few minutes.

Now, this method isn’t 100% optimal, as it downmixes the surround sound track into an AAC stereo sound track. I need to work out a way to keep the surround information.

10 thoughts on “Quick MKV to MP4 conversion without transcoding

  1. could also try using ffmpeg.

    I use that to ‘repack’ .dvr-ms (from media center) to mpeg2 with out recompressing

  2. Yes, I’m also investigating using ffmpeg and mp4creator to demux/remux the MKV into an MP4. It all appears to work OK when the file is smaller than 4GB, but lots of strange errors seem to happen, even when enabling 64 bit stuff in mp4creator.

    Here’s what I was doing:

    #find out what track number is the video track in the mkv
    #also check the frame rate
    mkvinfo $INPUT.mkv

    #demux the video stream as video.h264
    mkvextract tracks $INPUT.mkv $TRACKNUMBER:video.h264

    #demux the audio stream as audio.aac
    ffmpeg -i $INPUT.mkv -vn -acodec libfaac -ac 6 audio.aac

    #use hexeditto check the profile
    #open video.h264 in hexedit and if the first line contains:
    # 67 4D 40 33
    #
    #change to:
    #
    # 67 4D 40 29

    #use mp4creator to create
    mp4creator -use64bits -create=video.h264 -rate=$FRAMERATE $OUTPUT.mp4

    #add a hint track for the video:
    #this is where it flips out if my file is close to, or bigger than 4GB.
    #can also tell the previous step to hint the file, but that also fails on large files.
    mp4creator -hint=1 file.mp4

    #mux the audio in, interleave it with the video and optimise it for streaming
    mp4creator -c audio.aac -interleave -optimize $OUTPUT.mp4

  3. it is so complicted to do as yur ways
    what i use is brorsoft mkv converter which can convert mkv to almost all vidoe formats,such as avi,mp4,mp3,mav,wma,wov,acc,flac and so on.

  4. Very easy in Windows with only one tool (XMedia Recode): just activate the copy tag for both the video and the audio track.

  5. I’m sorry I didn’t read your full post.. but if you’re just trying to repack an mkv file into an mp4.. all you need is a nifty little program called GOTSent… it’s free.. and it takes no more than a couple of mins for the repacking/conversion.. I believe it’ll also re-encode your audio without touching the video. Look it up!

Leave a Reply to Kai HowellsCancel reply