AVAssetReader,如何与流而不是文件一起使用? [英] AVAssetReader, how to use with a stream rather than a file?

查看:126
本文介绍了AVAssetReader,如何与流而不是文件一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AVAssetReader很棒,但是我只能看到如何将其与本地资产,文件或我认为是合成物一起使用

AVAssetReader is fantastic, but I can only see how to use it with a local asset, a file, or I guess a composition,

所以

assetReader = try AVAssetReader(asset: self.asset)
...
assetReader.addOutput(readerOutput)

以此类推,

说您的视频流到了

(也许是苹果公司的.M3U8文件示例,

(perhaps Apple's examples of .M3U8 files,

https://developer.apple.com/streaming/examples/)

实际上,AVASsetReader可以用于流吗?还是只有本地文件?

In fact, can AVAssetReader be used for streams? Or only local files?

我只是无法在任何地方找到解释. (也许很明显,如果您更熟悉它.:/)

I just plain cannot find this explained anywhere. (Maybe it's obvious if you're more familiar with it. :/ )

推荐答案

这不是很明显.将AVAssetReaderAVComposition的头文件注释拼凑在一起,给人的印象是只为本地资产设计的API,尽管该语言并未明确排除非本地资产.

It's not obvious. Patching together the header file comments for both AVAssetReader and AVComposition gives the strong impression of an API designed only for local assets, although the language does not explicitly rule out non-local assets.

AVAssetReader头文件中:

AVAssetReader的实例从AVAsset的实例读取媒体数据,无论资产是基于文件的还是代表来自多个源的媒体数据的集合,如AVComposition一样.

Instances of AVAssetReader read media data from an instance of AVAsset, whether the asset is file-based or represents an assembly of media data from multiple sources, as is the case with AVComposition.

和来自AVComposition:

AVComposition以自定义的时间安排组合来自多个基于本地文件的源的媒体数据,以便一起呈现或处理来自多个源的媒体数据.不论容器类型如何,所有基于本地文件的视听资产都可以合并.

An AVComposition combines media data from multiple local file-based sources in a custom temporal arrangement, in order to present or process media data from multiple sources together. All local file-based audiovisual assets are eligible to be combined, regardless of container type.

如果您仅对视频感兴趣,并且不介意在播放过程中进行处理,则可以通过在AVPlayerItem中添加AVPlayerItemVideoOutput来捕获远程资产中的帧.如果您对音频感兴趣,那您就小溪了.

If you're interested in video only, and don't mind processing as part of playback, you can capture frames from a remote asset by adding an AVPlayerItemVideoOutput to your AVPlayerItem. If you're interested in audio, you're up a creek.

这篇关于AVAssetReader,如何与流而不是文件一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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