AVAssetReader 非常棒,但我只能看到如何将它与本地 Assets 、文件或我猜的组合一起使用,
所以,
assetReader = try AVAssetReader(asset: self.asset)
...
assetReader.addOutput(readerOutput)
等等,
假设您有一个到达流
(也许是 Apple 的 .M3U8 文件示例,
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/