Tuesday, March 19, 2024
Username: Password:
Home > English Homepage > English tutorials > Media streaming and playback > Howto: 720p MKV playback on an iPhone 4
[NEWS]
Added by unreal
UPDATE! Now with preconfigured bundle for OS X! Read on...

In the same way we were able to play MKV content on a PS3, we are going to play 720p MKV content on an iPhone 4 or iPod Touch with Retina display without re-compressing the video.

The iPhone 4 specifications page shows that 720p H.264 Main@L3.1 content is supported, with AAC@160kbit/s sound, inside a mp4 container. That means we'll have a few tasks to complete before being able to play MKV files on the iPhone 4. To start with, we'll need to compress the original sound track (usually AC3 or DTS 5.1) into AAC, then we'll need to make sure the video is ML@3.1, and finally we'll remux the streams into a mp4 container.

As far as the video is concerned, the main problem is going to be that most HD TV series use L4.1 or High@L3.1 H264 content. For example, we can see my test file is using High@L3.1 using mediainfo:

$ mediainfo /usr/home/exports/file.mkv | grep Format
Format                         : Matroska
Format                         : AVC
Format/Info                     : Advanced Video Codec
Format profile                 : High@L3.1
Format settings, CABAC         : Yes
Format settings, ReFrames        : 3 frames
Format                         : AC-3
Format/Info                     : Audio Coding 3


The iPhone will not even try to play the H264 stream because it checks the header information for compatible profiles. That doesn't mean other profiles will not play, it justs means that Apple cannot guaranty they will. So, we will rewrite the header information to "fowl" the iPhone, which will work fine if the encoding options (mainly refs, bframes and b_pyramids) are not too high. I've done some testing and 720p videos with a 5 Mbit/s bitrate play just fine, and they look great on the high-def screen.

Practical work

We're going to use the MKV2MP4 conversion script, so download it here.

You can also download a special Mac OS X version containing all the necessary binaries by clicking here. Since this version is preconfigured, jump straight to the howto section.

Start by editing the script to force the header to MP@L3.1:

MAGIC_H264="6764001F"


Before running the script, you'll need to install a few tools:

- mkvtoolnix
- FFMpeg with AAC encoding
- MP4box or MP4Creator

The script is really simple to use:

./mkv2mp4.sh /path/to/file.mkv


The .mp4 files produced by the script will be saved to the same folder as the original mkv source file.

It is possible to specify a destination folder, which will be created if it doesn't exist:

./mkv2mp4.sh /path/to/file.mkv /home/media


Now using iTunes, transfer the mp4 files to your iPhone 4 or iPod Touch (with Retina display).

Changelog

- Oct 16 2010: first version
- August 14 2011: update with Mac OS X version

Posted on 18/10/10 at 14:37

Howto: 720p MKV playback on an iPhone 4
You could comment this news if you had an account!