Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何将预期帧速率设置为AVAssetWriterInput_Ios_Video_Frame Rate_Avassetwriter_Avassetwriterinput - Fatal编程技术网

Ios 如何将预期帧速率设置为AVAssetWriterInput

Ios 如何将预期帧速率设置为AVAssetWriterInput,ios,video,frame-rate,avassetwriter,avassetwriterinput,Ios,Video,Frame Rate,Avassetwriter,Avassetwriterinput,我有一个应用程序,它以不同的方式编码视频,并将其保存到照片库中-它可以剪切特定的时间范围,添加图片、文本等。在我尝试编码视频120+fps之前,一切都很正常。问题是,视频似乎动作缓慢,我根本不追求这个目标 我找到了名为AVVideoExpectedSourceFrameRateKey的AVAssetWritterInput的属性,但问题是,当我尝试将此参数应用于我的AVAssetWritterInput时,出现以下错误: ***由于未捕获的异常“NSInvalidArgumentExceptio

我有一个应用程序,它以不同的方式编码视频,并将其保存到照片库中-它可以剪切特定的时间范围,添加图片、文本等。在我尝试编码视频120+fps之前,一切都很正常。问题是,视频似乎动作缓慢,我根本不追求这个目标

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

***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'***-[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:]输出设置字典包含一个或多个无效键:ExpectedFrameRate'

这是我的
AVAssetWriterInput
初始化,一点也不奇怪:

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

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

问题来自于您在字典中放置键以将设置加载到outputSettings的方式。键“AVVideoExpectedSourceFrameRateKey”实际上应该放在嵌套字典中,它的键是“AVVideoCompressionPropertiesKey”。因此,您有一个字典的排序作为输出设置。它应该是这样的:

let outputSettings:[String: Any] = [
            AVVideoCodecKey: AVVideoCodecJPEG,
            AVVideoHeightKey: correctedContentSize.height,
            AVVideoWidthKey: correctedContentSize.width
            AVVideoCompressionPropertiesKey: 
               [AVVideoExpectedSourceFrameRateKey: 60]                                         
        ]
如果您想在播放此视频时使用此选项调整提要,可以在此处找到有关此过程的更多信息:


我也遇到了同样的问题。你解决了吗?你好@gstream79!如果我没有记错的话,key
AVVideoExpectedSourceFrameRateKey
应该放在
avvideocompressionproperties key
或者类似的东西中。但我不确定,因为我最终没有使用此属性。感谢您的回答@Eugene Alexeev,我尝试使用AVVideoExpectedSourceFrameRateKey,但没有成功。您是如何解决此问题的?你不得不放弃?还是使用另一种方法设置fps?