AVFoundation (AVPlayer) supported formats? No .vob or .mpg containers?

The AVURLAsset class has a static methods that you can query for supported video UTIs:

+ (NSArray *)audiovisualTypes

On 10.9.1 it returns these system defined UTIs:

  • public.mpeg
  • public.mpeg-2-video
  • public.avi
  • public.aifc-audio
  • public.aac-audio
  • public.mpeg-4
  • public.au-audio
  • public.aiff-audio
  • public.mp2
  • public.3gpp2
  • public.ac3-audio
  • public.mp3
  • public.mpeg-2-transport-stream
  • public.3gpp
  • public.mpeg-4-audio

Here is an explanation of system UTIs. So it seems that at least the .mpg container should be supported.

According to wiki, .mpg files can contain MPEG-1 or MPEG-2 video, but only MPEG-2 video is supported. So maybe that's why the file loads but nothing is displayed.

QuickTime internally uses QTMovieModernizer in order to play videos in legacy formats (as mentioned in this WWDC session), so maybe you can look into that. It even has a method for determining if a file needs to be modernized:

+ requiresModernization:error:

To get a list of supported extensions, you can use the following function:

import AVKit
import MobileCoreServices

func getAllowedAVPlayerFileExtensions() -> [String] {
    let avTypes = AVURLAsset.audiovisualTypes()
    var avExtensions = avTypes.map({ UTTypeCopyPreferredTagWithClass($0 as CFString, kUTTagClassFilenameExtension)?.takeRetainedValue() as String? ?? "" })
    avExtensions = avExtensions.filter { !$0.isEmpty }
    return avExtensions
}

This will return a list like so:

["caf", "ttml", "au", "ts", "mqv", "pls", "flac", "dv", "amr", "mp1", "mp3", "ac3", "loas", "3gp", "aifc", "m2v", "m2t", "m4b", "m2a", "m4r", "aa", "webvtt", "aiff", "m4a", "scc", "mp4", "m4p", "mp2", "eac3", "mpa", "vob", "scc", "aax", "mpg", "wav", "mov", "itt", "xhe", "m3u", "mts", "mod", "vtt", "m4v", "3g2", "sc2", "aac", "mp4", "vtt", "m1a", "mp2", "avi"]