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

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-28 06:00:27

问题


Using AVPlayer in a Mac app here to play random videos in fullscreen from a folder, but when I try to play .vob files or .mpg files I just get a black screen that lasts as long as the video lasts.

Does AVFoundation not support playback from these containers? I figured that since they were playable with stock QuickTime Player they would also work with AVPlayer.


回答1:


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:


来源:https://stackoverflow.com/questions/21879981/avfoundation-avplayer-supported-formats-no-vob-or-mpg-containers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!