【发布时间】:2017-05-16 12:35:07
【问题描述】:
我正在尝试在 iOS 中重新编码具有可变帧速率和持续时间剪辑的输入 MOV 文件。目前我有一个 AVAssetWriter 设置视频属性有点像这样:
NSMutableDictionary* compressionPropertiesDict = [NSMutableDictionary new];
compressionPropertiesDict[AVVideoProfileLevelKey] = AVVideoProfileLevelH264High40;
if(self.fps > 0) {
compressionPropertiesDict[AVVideoAverageNonDroppableFrameRateKey] = [NSNumber numberWithInt:self.fps];
_sessionMgr.videoSettings = @
{
AVVideoCodecKey: AVVideoCodecH264,
AVVideoWidthKey: [NSNumber numberWithFloat:self.outputSize.width],
AVVideoHeightKey: [NSNumber numberWithFloat:self.outputSize.height],
AVVideoCompressionPropertiesKey: compressionPropertiesDict,
};
在运行时显示如下:
videoSettings =
{
AVVideoCodecKey = avc1;
AVVideoCompressionPropertiesKey = {
AverageNonDroppableFrameRate = 15;
ProfileLevel = "H264_High_4_0";
};
AVVideoHeightKey = 960;
AVVideoWidthKey = 640;
}
最后,我遇到了NSInvalidArgumentException:
"Compression property AverageNonDroppableFrameRate is not supported for video codec type avc1" 的崩溃。 (在使用模拟器的单元测试中。)
只有一种编解码器类型可以在 iOS 中使用,AVVideoCodecH264 / "avc1" - 我注意到其他项目使用了 AVVideoAverageNonDroppableFrameRateKey。事实上,我使用的是SDAVAssetExportSession,在那个代码库中我看到了这个键的明确使用。所以我会认为必须有一种方法可以使用这个键来设置帧率..?
我也尝试过使用AVVideoMaxKeyFrameIntervalKey 来代替,但这根本不会改变我的帧速率...
所以,总而言之,谁能帮我为基于 iOS AVFoundation 的视频转换设置不同的(总是较低的)输出帧速率?谢谢!
【问题讨论】:
-
您找到解决方案了吗?
-
啊是的,我做了,将作为答案发布!
标签: ios avfoundation avassetwriter