ios - AVAssetReader,如何使用流而不是文件?

标签 ios swift avfoundation avassetreader

AVAssetReader 非常棒,但我只能看到如何将它与本地 Assets 、文件或我猜的组合一起使用,

所以,

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

等等,

假设您有一个到达流

(也许是 Apple 的 .M3U8 文件示例,

enter image description here

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

其实AVAssetReader可以用于流吗?还是只有本地文件?

我只是在任何地方都找不到这个解释。 (如果你更熟悉的话,也许这是显而易见的。:/)

最佳答案

这并不明显。将 AVAssetReader 的头文件注释修补在一起和AVComposition尽管该语言没有明确排除非本地 Assets ,但给人留下了仅针对本地 Assets 设计的 API 的强烈印象。

来自AVAssetReader头文件:

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 :

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.

如果您仅对视频感兴趣,并且不介意将处理作为播放的一部分,则可以通过添加 AVPlayerItemVideoOutput 从远程资源捕获帧。给您AVPlayerItem 。如果您对音频感兴趣,那么您就已经成功了。

关于ios - AVAssetReader,如何使用流而不是文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53796395/

相关文章:

ios - 如何计算动态类型的 estimatedRowHeight

ios - OSX 上的 AVAudioSession 替代方案以获取音频驱动程序采样率

ios - 我想知道如何测试sqlite中的compileStatement是否返回答案,而不错过第一行

ios - 在 Controller 之间传递数据的最佳性能

iphone - 如何在 Xcode for iPhone 中制作多页面应用程序?

ios - 取消firebase功能

ios - 在 iPhone 上将照片保存到磁盘的最有效内存方式?

ios - 使用 AVFoundation 暂停视频录制

ios - 如何在 swift 中的 do 函数中为字符串添加 +1 以进行分页

ios - StoreKit 框架