ios 如何使用 AVAssetWriter?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3728311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:44:14  来源:igfitidea点击:

How do I use AVAssetWriter?

iosavfoundationavassetwriter

提问by zoul

I'd like to take some video frames and encode them into a video. It looks like that's exactly what AVAssetWriterwas meant for, but no matter how I eyeball the docs and Google I?can't find any way to actually use it. From the docs it looks like I need an input (AVAssetWriterInput) to feed the writer from. Fine. But the AVAssetWriterInputclass is abstract and the only subclass that I know of in 4.1 is AVAssetWriterInputPixelBufferAdaptorthat requires a AVAssetWriterInputin its initializer…? Am I missing something obvious here?

我想拍摄一些视频帧并将它们编码成视频。看起来这正是它的AVAssetWriter意思,但无论我如何查看文档和谷歌,我都找不到任何实际使用它的方法。从文档看来,我需要一个输入 ( AVAssetWriterInput) 来为作者提供信息。美好的。但是这个AVAssetWriterInput类是抽象的,我在 4.1 中所知道的唯一子类是它的初始值设定项AVAssetWriterInputPixelBufferAdaptor中需要 a AVAssetWriterInput......?我在这里遗漏了一些明显的东西吗?

采纳答案by zoul

Ah yes, I have to acquire an instance using +[AVAssetWriterInput assetWriterInputWithMediaType:outputSettings:], see my postunder a different question for a?detailed code sample.

是的,我必须使用 获取实例+[AVAssetWriterInput assetWriterInputWithMediaType:outputSettings:],请参阅我在不同问题下的帖子以获取详细代码示例。