How to set expected framerate to AVAssetWriterInput

戏子无情 提交于 2020-01-02 07:41:30

问题


I have an app which encodes videos in different ways and saves it to Photos library - it can cut specific time range, add pictures, text, etc. Everything is working perfectly till I try to encode video 120+ fps. The problem is that video appears to be slow-motioned and I don't pursue that goal at all.

Here I found out about property for AVAssetWritterInput which is called AVVideoExpectedSourceFrameRateKey, but the problem is that when I try to apply this parameter to my AVAssetWritterInput, I'm getting this error:

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

Here's my AVAssetWriterInput initialization, nothing fancy at all:

let input = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: [AVVideoCodecKey: AVVideoCodecJPEG,
                                                                                         AVVideoHeightKey: correctedContentSize.height,
                                                                                         AVVideoWidthKey: correctedContentSize.width,
                                                                                         AVVideoExpectedSourceFrameRateKey: 60])

Any help would be appreciated. Thanks.

来源:https://stackoverflow.com/questions/49436027/how-to-set-expected-framerate-to-avassetwriterinput

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!