【发布时间】:2018-09-01 07:49:06
【问题描述】:
我有一个应用程序,它以不同的方式对视频进行编码并将其保存到照片库 - 它可以缩短特定的时间范围、添加图片、文本等。在我尝试对 120+ fps 的视频进行编码之前,一切都运行良好。问题是视频看起来是慢动作的,我根本不追求这个目标。
Here 我发现AVAssetWritterInput 的属性称为AVVideoExpectedSourceFrameRateKey,但问题是当我尝试将此参数应用于AVAssetWritterInput 时,我收到此错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:] Output settings dictionary contains one or more invalid keys: ExpectedFrameRate'
这是我的AVAssetWriterInput 初始化,没什么花哨的:
let input = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: [AVVideoCodecKey: AVVideoCodecJPEG,
AVVideoHeightKey: correctedContentSize.height,
AVVideoWidthKey: correctedContentSize.width,
AVVideoExpectedSourceFrameRateKey: 60])
任何帮助将不胜感激。谢谢。
【问题讨论】:
-
我遇到了同样的问题。你解决了吗?
-
你好@gstream79!如果我没记错的话,应该将密钥
AVVideoExpectedSourceFrameRateKey放入AVVideoCompressionPropertiesKey或类似的东西中。但我不确定,因为我最终没有使用这个属性。 -
感谢您的回答@Eugene Alexeev,我尝试使用 AVVideoExpectedSourceFrameRateKey 但没有运气。
-
你是怎么解决这个问题的?你不得不放弃?还是使用其他方式设置 fps ?
标签: ios video frame-rate avassetwriter avassetwriterinput