Convert mkv movies into mp4

Discussion in 'Apple TV and Home Theater' started by Aegelward, Apr 30, 2007.

  1. Aegelward macrumors 6502a

    Joined:
    Jul 31, 2005
    Location:
    UK
    #1
    i was wondering if there was any way to convert an h.264 mkv file (with subtitles) into a mp4/m4v file, without having to re-encode it, but allow for adding meta data. viddyup does this to an extent, but it is limited to converting the file into an .mov, which within itunes isn't maintaining chapter data (they show, but the markers are all set at 0:00. curiously they still work under regular quicktime)

    but i would also like to add art, and other metadata which the .mov format won't allow...
     
  2. speakerwizard macrumors 68000

    speakerwizard

    Joined:
    Aug 8, 2006
    Location:
    London
    #2
    avoid mkv if you can, its possible to convert but far too much effort, if you search my early posts there is a thread about it but just EFFORT
     
  3. Blazer5913 macrumors 6502

    Joined:
    Jan 20, 2004
    #3
    Use VisualHub. I just bought it to convert about 200gb of High Def videos to work on my AppleTv. Looking great soo far
     
  4. oldmanuk macrumors newbie

    Joined:
    May 1, 2007
    #4
    Use mkvextract and MP4Box
    http://www.bunkus.org/videotools/mkvtoolnix/
    http://gpac.sourceforge.net/

    mkvextract tracks temp.mkv 1:temp.aac 2:temp.h264
    FPS=`mkvinfo temp.mkv | gawk '/[0-9.]\ fps/ { print $6 }' | gawk -F\( '{ print $2 }' | tail -1`
    MP4Box -add temp.aac -add temp.h264 -fps $FPS temp.mp4

    Not sure what you wanted to do with the subtitles though, ISO .mp4 doesn't support them...
     
  5. daze macrumors 6502

    daze

    Joined:
    Mar 11, 2006
    Location:
    San Jose, California
    #5
    Excellent tip there. Thanks so much!
     
  6. rodti macrumors member

    rodti

    Joined:
    Jul 31, 2006
    Location:
    Scotland
    #6
     
  7. gnkieffer macrumors newbie

    Joined:
    Dec 16, 2007
    #7
    I found a very simple way to convert MKV to MP4 without using command line tools and with no re-encoding of the video stream, no quality lost. It requires Quicktime Pro and Perian. I wrote a quick tutorial with screen shots on my blog.
    You only need to export the movie using Quicktime and yesssss, there is a Pass Through option for the video :D Quicktime always surprises me :apple:
     
  8. wmealer macrumors regular

    Joined:
    May 7, 2006
    #8
    I have seen this several times on the net, and every time I try it with any of my 720p mkv files, neither my :apple:tv nor my PS3 can recognize the resulting mp4 as a playable file.
     
  9. gnkieffer macrumors newbie

    Joined:
    Dec 16, 2007
    #9
    You may try to re-encode the video stream too. Maybe the streams in your MKV files were encoded with parameters unsupported by Apple TV / PS3. Or the bitrate might be to high.
    If you encode with quicktime within the bitrate and resolution limits of the Apple TV the resulting file must work, as Apple TV also uses Quicktime to decode it.

    Edit 2: According to the official Apple TV Tech Specs, a 720p file is even limited in its frame rate to be playable: max 24fps
     
  10. fkntotalkaos macrumors 6502

    Joined:
    Nov 24, 2007
    #10
    Great tutorial , but i have a few questions.
    Are you saying encode sound at 160? Because your settings are 256.
    And my inspector shows H.264 960 x 528, but i can not select pass through on video settings
     
  11. gnkieffer macrumors newbie

    Joined:
    Dec 16, 2007
    #11
    Thanks! You may use the bitrate you want but some devices may not play back high bitrates. The Apple TV for example only plays video files with up to 160kbps audio streams, not higher (according to Apple).

    Make sure that you have selected the Video Format MP4 and not MP4 (ISMA).
    It's the 5th screenshot in the tutorial. If you select the second option, then the Pass Through option will be grayed out.
     
  12. wmealer macrumors regular

    Joined:
    May 7, 2006
    #12
    Yes, I use VisualHub to re-encode the entire file, but I thought the idea of your post was to NOT touch the video, and have it playable on :apple:tv...

    This is an :apple:tv forum, after all...:rolleyes: No worries, I guess I'm just frustrated that :apple:tv can't handle the high-quality video contained in these great looking mkv files.
     
  13. fkntotalkaos macrumors 6502

    Joined:
    Nov 24, 2007
    #13
    I might have have found a work around. According to hackintosh, we can use t he new version of NitoTV to play .avi,.mk4 directyl
     
  14. wmealer macrumors regular

    Joined:
    May 7, 2006
    #14
    If it actually works, that's incredible news! I can't imagine nitoTV (mplayer) has a way of speeding up the :apple:tv's processor though. I'd assume it still boils down to that, unfortunately.
     
  15. stomer macrumors 6502a

    Joined:
    Apr 2, 2007
    Location:
    Leeds, UK
    #15
    Matroska files give me all sorts of file. This is what I've learned so far

    - If the MKV contains AAC 5.1, then don't bother resampling it. For one thing VisualHub can't resample it, and resampling in Quicktime induces a delay so that the audio and video are out of sync. Besides, it seems that ATV can handle the 5.1 just fine.
    - The H.264 contained within an MKV file will almost always require re-encoding. I've yet to come across an H.264 that can be played on my ATV without a re-encode. Apparently there's a tool called h264info that can set the video from 5.1 to 4.1, which may allow it to play on ATV, but I've yet to find a Mac binary of h264info. [UPDATE] BTW, forget about h264info, it's Windows only. Unless you fancy running it in a VM. Personally, it's easier for me to just re-encode.

    So, if the audio is AAC 5.1, then my workflow is as follows:

    1. Run mkvextract and demux the audio and video.
    2. Run MP4box and remux the audio and video into an MP4
    3. Run VisualHub and apply the setting -acodec copy. This will passthrough the audio without the need to re-encode.
    4. You should now have an MP4 that can be played on ATV
     
  16. nicoska macrumors member

    Joined:
    Jun 16, 2007
    #16
    Wow!
    Thanks for your precius tips.
    I'll try this at home.
    Bye

    nico
     
  17. stomer macrumors 6502a

    Joined:
    Apr 2, 2007
    Location:
    Leeds, UK
    #17
    I've been able to add subtitles using MP4Box and VLC seems to display them back perfectly. Are you saying that this is non-standard operation?
     
  18. stomer macrumors 6502a

    Joined:
    Apr 2, 2007
    Location:
    Leeds, UK
    #18
    Unfortunately MP4Box will sometimes stall when you try to remux on step 2. I'm determined to get this working, so I've found another way to get your mkv's into mp4s.

    If you drag and drop the mkv into Visual Hub, it will complain about the audio being in 5.1. It will fail even if you set the audio to passthough (using -acodec copy). Instead we pass the -an flag which tells Visual Hub to completely ignore the audio.

    1. Open visual hub, enter the -an flag in the extra ffmpeg field in the advanced options, and start encoding.
    2. Once the encoding is finished we need to add the audio from the mkv. So in Terminal.app run
    Code:
    mkvextract tracks mymovie.mkv 2:audio.aac
    3. Run:
    Code:
    MP4Box -add audio.aac mymovie.mp4
    Now you should hopefully have an Apple TV compatible MP4.
     
  19. Scandals macrumors member

    Joined:
    Nov 30, 2004
    Location:
    Canada
    #19
    this works? i have some downloaded .mkv files that are H.264 with 5.1 AAC and the video plays in QuickTime (perian), but there is no audio. I tried to convert the 5.1 AAC to stereo, but I can't for the life of me figure out if it is possible or even if that is the problem??? :confused:

    I am on Leopard and have heard that there is a bug in quicktime 7.3. Is this true?

    Can you guys play 5.1 AAC mp4s in iTunes and AppleTV?? I hate transcoding everything. :mad:
     
  20. stomer macrumors 6502a

    Joined:
    Apr 2, 2007
    Location:
    Leeds, UK
    #20
    Well, that particular file won't work AppleTV. If all you want to do is to watch the movie on your Mac, then just use VLC.

    Seems to work for me.
     
  21. zero_bit macrumors newbie

    Joined:
    May 3, 2005
    #21
    Stomer - thanks immensely for your help! Since you figured it out for mkv, I've got to ask-- what is your process for wmv files that have 5.1 DTS? Quicktime won't open them (it crashes) and VH gives the typical "boo hoo, 5 channel sound" error.

    edit: ok, the very second I posted this, Quicktime finally opened the file (it must've been 30 minutes loading). I wonder if that means anything =P
     
  22. Scandals macrumors member

    Joined:
    Nov 30, 2004
    Location:
    Canada
    #22
    All i want to do is be able to convert 720p .mkv files (x264+5.1AAC) into a format that will play nice with :apple:TV. I can't for the life of me figure out how to deal with the audio. All of the conversion tools, including QuickTime, seem to reject it. VLC is the only thing that works and that doesn't help my :apple:TV at all.
     
  23. stomer macrumors 6502a

    Joined:
    Apr 2, 2007
    Location:
    Leeds, UK
    #23
    Sorry, I can't be of much help. The files that I download are always either AVI or MKV. However, if you get Visual Hub to get you the TV compatible video in MP4 (using the -an), then you may be able to convert the audio using besweet or something similar. Then afterwards remux using MP4Box or Quicktime Pro.
     
  24. stomer macrumors 6502a

    Joined:
    Apr 2, 2007
    Location:
    Leeds, UK
    #24
    Are you saying that your 5.1 audio doesn't play on the TV?
    I've not tried this but I it could work. If you follow my instructions mentioned earlier, then you'll have an MP4 containing TV compatible video and 5.1 audio. Using Quicktime Pro, open your MP4, choose export from the file menu, in the options, select passthrough for the video, and then downsample the audio. That might work.
     
  25. nicoska macrumors member

    Joined:
    Jun 16, 2007
    #25
    Please, could you post the exact terminal command ?
    Thaks a lot

    Nico
     

Share This Page