4
votes

I'm creating an iPhone app which can manipulate video files. I'm using AVFoundation classes (e.g., AVAsset). I just registered my application as a handler of all files conforming to public.movie (via CFBundleDocumentTypes). However, now my application is listed in the "Open With" menu for .avi files, even though I don't think iOS can play AVI movies (the Quick Look preview will try, but fails).

Is there a better way to register to open movies? I will also need to support File Sharing, so I need to distinguish which files in the Documents folder are valid movies as well, though I haven't figured out how to check the UTI of a file. The iOS Technology Overview says:

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”

Thanks in advance for any tips you might have.

2

2 Answers

4
votes

For video only, specifying the following UTIs in the Info.plist should work:

  • com.apple.m4v-video (.m4v)
  • com.apple.quicktime-movie (.qt, .mov)
  • public.mpeg-4 (.mp4)

You can find the UTIs supported by AVFoundation in AVMediaFormat.h: https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVFoundation_Constants/Reference/reference.html%23//apple_ref/doc/uid/TP40009539-CH4g-DontLinkElementID_48

2
votes

I've decided the best way to handle this is to determine the UTI of a file using the UT* functions to get a UTI from a file extension. Unfortunately this means that AVI files are still imported, because the OS knows they're movies even though they can't be played, but it doesn't seem to be causing too many problems.