AVFoundation - 重新编码视频文件的最佳方法是什么(添加更多关键帧)?

时间:2017-08-14 00:51:16

标签: cocoa cocoa-touch avfoundation

我有一个不能准确搜索的mp4文件,向后搜索很慢。我认为它是由压缩程度很高的编码引起的。

使用AVFoundation重新编码此文件的最佳方法是什么,以便我可以将每个帧作为关键帧?

1 个答案:

答案 0 :(得分:0)

设置(最大)关键帧间隔的标准方法是AVVideoMaxKeyFrameIntervalKey

  

相应的值是NSNumber的实例。 1表示关键帧   仅

您可以将它应用于AVAssetWriter对象,该对象可能与此类似:

NSDictionary *compProps = @{ AVVideoAverageBitRateKey : @(bitsPerSecond), 
                             AVVideoExpectedSourceFrameRateKey : @(30),
                             AVVideoMaxKeyFrameIntervalKey : @(1) };

_videoInput = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeVideo 
                                          outputSettings:compProps];

AVVideoMaxKeyFrameIntervalKey