12

What video formats are compatible with the iPhone's assets library?

In other words, for what video formats will ALAssetsLibrary's videoAtPathIsCompatibleWithSavedPhotosAlbum return YES?

I can't seem to locate any information on this in the iPhone Reference Library.

Avalanchis
  • 4,500
  • 3
  • 39
  • 48

5 Answers5

14

No one has mentioned this yet, but it depends on the iPhone / iOS device. In making an app that tries to copy Flickr videos to the photo album, I was getting frustrated when I kept getting invalid data results on writeVideoAtPathToSavedPhotosAlbum: calls for a non-Retina iPhone.

I ran some videoAtPathIsCompatibleWithSavedPhotosAlbum tests on Flickr videos of various sizes, as requested in this question.

                                  iPhone        iPhone       iPad
                               (non-Retina)    (Retina)
6119419764_orig.mov
H.264, 1,920 x 1,080               NO             NO          NO
Linear PCM, 16 bit 
little-endian signed 
integer, 48000 Hz, 
Stereo (L R)
35.33 Mbit/s

6119419764_hd.mp4
AVC Coding, 1,280 x 720            NO             YES         YES
AAC, 44100 Hz, Stereo (L R)
2.15 Mbit/s

6119419764_site.mp4
AVC Coding, 640 x 360              NO             YES         YES
AAC, 44100 Hz, Stereo (L R)
833.71 kbit/s

6119419764_mobile.mp4
AVC Coding, 568 x 320              YES            YES         YES
AAC, 32000 Hz, Mono
775.14 kbit/s

6121206003_orig.mov
(Taken with iPhone 3Gs)           
H.264, 480 x 360                   YES            YES         YES
AAC, 44100 Hz, Mono
865.94 kbit/s
30 fps

6110638568_reformat.mov
H.264, 640 x 360                   YES            YES         YES
AAC, 44100 Hz, Mono
3.57 Mbit/s

Based on this limited testing, for a given format and device, it looks like size matters most. (For the current Flickr encoding methods and url scheme, mobile videos work on all iOS device photo albums, whereas hd and site videos only work on Retina iPhones and iPads.)

An interesting side note is that HD videos will play on non-retina iPhones with the MPMoviePlayerController -- you just can't save them to the photo album.

Victor Van Hee
  • 9,679
  • 7
  • 33
  • 41
  • 1
    Nice detailed chart! Anecdotally, I have not yet found a case where MPMoviePlayerController will play a high-res video that doesn't make it into the CameraRoll - in particular videos taken with Galaxy S5 (not sure what settings, asked QA to use highest quality possible) won't play even on an iPhone 5C (didn't try 5S). But I don't have the level of detail you provide here regarding the characteristics of the videos. – Andy Weinstein Aug 11 '14 at 06:49
4

If you want a list of supported audio/video technologies, read the iOS Technology Overview, in particular the Media Layer (scroll down to where it says "Video Technologies").

The video technologies in iOS support the playback of movie files with the .mov, .mp4, .m4v, and .3gp filename extensions and using the following compression standards:

  • H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

  • H.264 video, up to 768 Kbps, 320 by 240 pixels, 30 frames per second, Baseline Profile up to Level 1.3 with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

  • MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

  • Numerous audio formats, including the ones listed in “Audio Technologies”

That's the reference information for the media frameworks in iOS.

Jano
  • 62,815
  • 21
  • 164
  • 192
3

I recently added a video export feature for the living photo burst of stills in my super-fast camera app SnappyCam Pro.

To cater for old and new devices alike, I ended up creating a few MPEG-4 "probe" videos, each with a single black frame, at a variety of 4:3 resolutions:

  1. 320x240px
  2. 640x480px
  3. 960x720px
  4. 1440x1080px

The four video files added just 12KB to the App Bundle.

By then iterating through each, with -[ALAssetsLibrary videoAtPathIsCompatibleWithSavedPhotosAlbum:], I was able to then work out which options are valid for the final Camera Roll video export.

jpap
  • 924
  • 11
  • 12
2

If I had to guess, I might use the iPhone's own specifications as a guideline for testing:

Video formats supported: H.264 video up to 720p, 30 frames per second, Main Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format

Alex Reynolds
  • 95,983
  • 54
  • 240
  • 345
  • Thanks for guessing, but I'd like to have a more definitive answer. Anyone care to do some testing to verify this? – Avalanchis Apr 28 '11 at 21:11
  • It would be odd for Apple's own specifications to be wrong, don't you think? – Alex Reynolds Apr 28 '11 at 21:32
  • Just because the iPhone supports a given video format, does not necessarily mean that the API in question accepts it. Although I don't have any information to suggest otherwise I was hoping someone could confirm that it indeed supports each of these formats. – Avalanchis Apr 29 '11 at 16:45
  • 1
    You can't use the specifications as a guideline, e.g. the iPhone3GS can playback 720p, but videoAtPathIsCompatibleWithSavedPhotosAlbum returns will not accept it. – Rhythmic Fistman Nov 16 '11 at 08:57
  • Which is why the developer does lots of testing. – Alex Reynolds Nov 16 '11 at 22:34
0

There doesn't seem to be a documented way to query what formats will make videoAtPathIsCompatibleWithSavedPhotosAlbum happy and the fact that a device can decode a certain format doesn't mean the AssetLibrary will accept it. However, you would expect that a camera equipped device will always be able to save the camera's highest resolution output to the camera roll.

If you can live with this assumption, then all you have to do is enumerate the AVCaptureDevices and query the various presets with supportsAVCaptureSessionPreset.

Victor's tests show that pixel area seems to matter most, so once you've queried AVCaptureSessionPreset1920x1080, AVCaptureSessionPreset1280x720, AVCaptureSessionPreset640x480 you should be able to choose a size that will make videoAtPathIsCompatibleWithSavedPhotosAlbum say YES.

I have no idea how you'd figure it for devices without cameras.

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159