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