首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将预期帧率设置为AVAssetWriterInput

如何将预期帧率设置为AVAssetWriterInput
EN

Stack Overflow用户
提问于 2018-03-23 02:31:26
回答 1查看 471关注 0票数 3

我有一个应用程序,它以不同的方式编码视频,并将其保存到图片库-它可以削减特定的时间范围,添加图片,文字等一切都是完美的,直到我尝试编码视频120+帧。问题是视频看起来动作很慢,而我根本就不追求这个目标。

Here我发现了名为AVVideoExpectedSourceFrameRateKeyAVAssetWritterInput的属性,但问题是,当我尝试将此参数应用于我的AVAssetWritterInput时,我收到以下错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:] Output settings dictionary contains one or more invalid keys: ExpectedFrameRate'

这是我的AVAssetWriterInput初始化,一点也不花哨:

代码语言:javascript
复制
let input = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: [AVVideoCodecKey: AVVideoCodecJPEG,
                                                                                         AVVideoHeightKey: correctedContentSize.height,
                                                                                         AVVideoWidthKey: correctedContentSize.width,
                                                                                         AVVideoExpectedSourceFrameRateKey: 60])

任何帮助都将不胜感激。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-03-08 01:43:32

问题来自于您将键放在字典中以将设置加载到outputSettings中的方式。关键字'AVVideoExpectedSourceFrameRateKey‘实际上应该放在一个嵌套的字典中,它的关键字是'AVVideoCompressionPropertiesKey’。因此,您有一本字典作为outputSettings。它应该看起来像这样:

代码语言:javascript
复制
let outputSettings:[String: Any] = [
            AVVideoCodecKey: AVVideoCodecJPEG,
            AVVideoHeightKey: correctedContentSize.height,
            AVVideoWidthKey: correctedContentSize.width
            AVVideoCompressionPropertiesKey: 
               [AVVideoExpectedSourceFrameRateKey: 60]                                         
        ]

如果您想在回放此视频时使用此功能调整提要,请在此处找到有关此过程的更多信息:

AVAssetWriter AVVideoExpectedSourceFrameRateKey (frame rate) ignored

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49436027

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档