Encoding settings for perfect iPad/iPhone video

You already know this, but iOS video is a big deal. Any serious video publisher either already supports iPad and iPhone, or needs to think hard about adding support. For some major publishers, iPad delivery represents 1/3 of total video views – or more.

Encoding for iOS is a little tricky, though. iOS devices have gone through several generations of technical capabilities, and the ideal video settings for the iPhone 4 are not ideal for the iPhone 3GS or for the iPad. Fortunately, with just a few encoding profiles, you can stream high quality video to every iOS device, from the first iPhone to the iPad 2, and even prepare for future generations of mobile hardware. We’ve written about this before but our previous guide only described how to ensure mobile compatibility – not how to find the best settings.

This article is the first in a series of encoding recommendations. At Zencoder, we get asked for encoding recommendations all the time, and we end up recommending the same (or similar) settings over and over. We’re going to start publishing our recommendations to our blog and to our docs in an effort to help Zencoder customers (and non-customers) make good decisions about how to encode video for a wide range of targets: mobile devices, Flash, Silverlight, HTML5, connected devices, and more.

(For deeper information on HLS and iOS video, be sure to download our guide to iOS video, which goes into more detail about HTTP Live Streaming and iOS video delivery.)

General settings

Like most video today, use H.264 video and AAC audio when targeting iOS. On the audio side, consider using HE-AAC at <64kbps, for App Store compliance. HE-AAC sounds reasonably good at these bitrates, even for complex audio. On the video side, use multiple profiles to target each device. iPhone 3GS and earlier only support H.264 Baseline profile, level 3.0 (and some support a more constrained version than that), whereas newer devices support Main and High profile.

For the best user experience, HTTP Live Streaming is a must. Apple requires it of any video app in the App Store that plays content longer than 10 minutes, and it is the only true streaming format supported by iOS. HLS is also being adopted by Android (version 3+), Roku, and a range of other destinations. Zencoder fully supports HLS, and does so better than anyone else in the cloud.

General approach

Resolution Profile Bitrate @ 16:9 @ 4:3 Audio Comments
1024×768 Main@3.1 2Mbps 1024×576 1024×768 56kbps HE-AAC
960×640 Main@3.1 1.5Mbps 960×540 854×640 56kbps HE-AAC
640×432 Main@3.1 1Mbps 640×360 576×432 56kbps HE-AAC
480×320 Baseline@3.0 600kbps 480×272 426×320 56kbps HE-AAC
400×288 Baseline@3.0 400kbps 400×224 384×288 56kbps HE-AAC
400×288 Baseline@3.0 200kbps 400×224 384×288 56kbps HE-AAC decimate frame rate
N/A (Audio Only) 56kbps HE-AAC

Why these recommendations?

  • These are just recommendations. Different resolutions and bitrates are perfectly valid, and may actually be preferable in some circumstances. For example, extremely complex content may warrant higher bitrates.
  • 720p is the largest video playable on iPad 1 and iPhone 4, and iPad 2/iPhone 4S play anything up to 1080p. But since the native display is only 1024 pixels wide, going all the way to 720p or 1080p isn’t critical. Unless, of course, you want to reuse a video somewhere else – 720p is a great resolution for fullscreen web playback, and 1080p is entirely appropriate for connected TVs. Future iPads, by the way, are rumored to have 4x the resolution of the current iPad, so consider adding 720p for future-proofing.
  • H.264 profile is important. iPad 1 and iPhone 4 both support Main profile. iPad 2/iPhone 4S support High profile, which is marginally better than Main, but given the tens of millions of iPad 1 devices in the world, it is probably better to stick to Main profile. Of course, for truly optimal device targeting, encode to both Main and High.
  • These 6 resolutions and bitrates provide reasonably good coverage of varying bandwidth. You could certainly do more – Apple recommends 8 – so add or subtract resolutions and profiles as desired.
  • Legacy iPhone/iPod Touch users will have three streams available to them, including a reasonably high quality 480×320 video (the screen resolution of these devices). iPad and iPhone 4 users will be able to make use of all six streams.
  • The resolution scaler on the iPad is pretty good, so videos that are rescaled will generally look good.
  • As much as possible, these settings allow for resolution dimensions divisible by 16. This makes for more efficient compression. The efficiency gains are small, especially at high resolutions, but at lower resolutions they start to make a difference.
  • Be sure to keep the audio identical across each video. If the audio specifications change from one version to another, the user may hear pops and clicks during playback when switching streams.

Other settings

  • Speed: set this based on desired turnaround time. For these recommendations, we’re going to use Speed 2, which improves compression a bit over the baseline but is still reasonably fast.
  • Peak limiting: ensure that each segment is roughly the same size by using a peak bitrate_cap of 150% of the target bitrate, but within a long buffer_size (e.g. 5 seconds, or 5x the bitrate_cap).
  • Zencoder automatically chooses proper keyframe placement when you set the type to “segmented”. If you’re encoding to MP4 for separate segmenting to HLS, set “forced_keyframe_rate” to “0.2” or “0.1” (for 5 or 10 second keyframe intervals, respectively).
  • If you can accept slightly unpredictable bitrates, add quality to the mix, and change video_bitrate to max_video_bitrate to optimize for file size. The encoder will use the max bitrate when needed, and will use a lower bitrate when it can achieve the desired quality with fewer bits.
  • Set the max_frame_rate to 30 and the max_audio_sample_rate to 48000.
  • The first generation if iOS devices only allow 1 H.264 reference_frame, so enable this on the Baseline streams for max compatibility.

For more information…

The Zencoder guide to HLS encoding – Best Practices for Encoding Video for iOS Devices – goes into more detail on the HLS standard, App Store requirements, advanced HLS features, and provides six tips for expert HLS encoding.

  • http://twitter.com/andershebert Anders Hebert

    How do you make sure devices won’t try accessing segments they can’t play? Do you have to publish separate m3u8-files for pre- and post-3GS or is there a way to tell older devices not to try the higher profiles?

  • http://twitter.com/andershebert Anders Hebert

    Never mind, I found the CODECS attribute, it seems to work. 

  • http://www.mindinventory.com/hire-ipad-developers.php hire ipad developer

    Development for iOS is a little challenging, though. iOS gadgets have gone through several years of specialized abilities, and the perfect movie configurations for the iPhone 4 are not perfect for the iPhone 3GS or for the iPad. Luckily, with just a few encoding information, you can flow top great quality movie to every iOS system, from the first iPhone to the iPad 2, and even get ready for years to come of cellular components.

  • http://www.eonlinegratis.com/2013/how-to-batch-convert-video-files-on-osx-for-appletv2-iphone4/ How To Batch Convert Video Files On OSX For AppleTV2 / IPhone4? | Click & Find Answer !

    […] forget to scale the video accordingly with -s:v 960×540 for example.See this blog entry for more info on encoding for Apple devices, which would go far beyond what I can explain here.While slhck has a pretty comprehensive answer, a […]

  • http://www.mindinventory.com/iphone_development.php iPhone Development

    If you’re getting a DVD you’re dealing with conventional importance movie, so the SD pre-specified is all you’ll need. If you’re modifying HD material, however, you have a choice. You can either convert the material to a complete 720p or use the iFrame pre-specified, which will make a pc computer file that’s roughly 960×540. This is half-1080p top quality and is a figure the apple organization company organization company wants to advertise for HD material.

  • http://www.mindinventory.com/iphone_development.php iPhone Development

    If you scribe your own movie for viewing on various gadgets and you’re looking to secured every last MB on your iPhone, it could be value you’re a while to try to re-encode at least some of your bigger details information with more traditional choices.

  • Anonymous

    This is some kind of a good approach in all of the iPad users. all of these things are really good to learn specially for the encoding techniques that you shared. Thanks for giving some great point of info’s here.

  • http://www.cloudstaff.com/ Ramon Andrews

    Thank you for sharing these encoding settings. iPad users will surely find this article helpful. Cheers!

  • http://www.process-box.com/ Clarissa Lucas

    Thank you for sharing these very helpful recommendations!

  • Anton Zuykov

    it is not iOS specific – you will get the same thing with old Android phones for exactly the same reasons

blog comments powered by Disqus