AVFoundation(AVPlayer)支持的格式?没有.vob或.mpg容器? [英] AVFoundation (AVPlayer) supported formats? No .vob or .mpg containers?

查看:97
本文介绍了AVFoundation(AVPlayer)支持的格式?没有.vob或.mpg容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此处使用Mac应用程序中的AVPlayer在全屏播放文件夹中的随机视频,但是当我尝试播放.vob文件或.mpg文件时,我只会得到一个黑屏,持续时间与视频持续时间一样.

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.

AVFoundation不支持从这些容器中回放吗?我认为,由于它们可以与库存的QuickTime Player一起播放,因此它们也可以与AVPlayer一起使用.

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.

推荐答案

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

+ (NSArray *)audiovisualTypes

在10.9.1上,它返回以下系统定义的UTI:

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
  • 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

这是对系统UTI的解释 .因此,似乎至少应该支持.mpg容器.

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

根据Wiki ,.mpg文件可以包含MPEG-1或MPEG-2视频,但只能包含MPEG-2视频受支持.所以也许这就是为什么文件加载但什么都不显示的原因.

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内部使用 QTMovieModernizer 来播放视频以旧格式(如此WWDC会话中所述),因此也许您可以对此进行研究.它甚至提供了一种确定文件是否需要现代化的方法:

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:

这篇关于AVFoundation(AVPlayer)支持的格式?没有.vob或.mpg容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆