timdoug's interesting tidbits
Little bits of technical documentation and such. Hopefully helpful.
Converting a .mkv file to .mp4 to play on the iPad
Problem: you acquire a MKV file you want to play on your iPad. It's already H264/AAC, which the iPad can handle, so you don't want to re-encode it.
Solution: extract the tracks with mkvextract, and mux them into an iPad-friendly MP4 with MP4Box.
- Get a GPAC Subversion snapshot from http://gpac.sourceforge.net/.
- Build it. It's a bit finicky, and it will probably crap out looking for nonexistent wxwidgets libraries, but hopefully before that it'll create an MP4Box binary in bin/gcc.
- Grab a Mac OS X binary of MKVToolnix. Its dependencies are pretty extensive, so I used the binary available here.
- Determine what's in the mkv container: Mkvtoolnix.app/Contents/MacOS/mkvinfo Foo.mkv
- It'll tell you that, e.g., track one is H264 video at 24 fps, and track two is AAC.
- Extract the tracks accordingly: Mkvtoolnix.app/Contents/MacOS/mkvextract tracks Foo.mkv 1:Foo.h264 2:Foo.aac
- Put them back together in an MP4: MP4Box -add Foo.aac -add Foo.h264 -fps 24 Foo.mp4
Sometimes, though, you'll get audio in a non-AAC format (e.g., MP3 or AC3). This requires conversion.
- Download, make, and install the libfaac library. (We'd use FFmpeg's internal AAC encoder, but currently it's broken.)
- Do the same with FFmpeg, making sure to point it to libfaac appropriately.
- Convert the extracted audio file to AAC: ffmpeg -i Foo.ac3 -acodec libfaac -ab 192k Foo.aac
- Then use MP4Box as before, but with your new .aac file.
Thanks to this
thread and this