我正在开发这款相机应用程序。在某些时候我试图写入视频,所以我正在创建一个assetWriter,我有这些行:
CGFloat videoFrameWidth = size.width;
CGFloat videoFrameHeight = size.height;
NSUInteger numPixels = videoFrameWidth * videoFrameHeight;
NSUInteger bitsPerSecond;
NSUInteger bitsPerPixel = 11.4; // This bitrate matches the quality produced by AVCaptureSessionPresetHigh... this was copied from a code from Apple
bitsPerSecond = numPixels * bitsPerPixel;
NSDictionary *videoCompressionSettings = @{AVVideoCodecKey : AVVideoCodecH264,
AVVideoWidthKey : @(videoFrameWidth),
AVVideoHeightKey : @(videoFrameHeight),
AVVideoCompressionPropertiesKey : @{ AVVideoAverageBitRateKey : @(bitsPerSecond),
AVVideoMaxKeyFrameIntervalKey : @(fps)}
};
if ([_assetWriter canApplyOutputSettings:videoCompressionSettings forMediaType:AVMediaTypeVideo])
如果我以1080p @ 30 fps进行录制,这种方法可以正常工作,但如果我切换到720p @ 60 fps,则最后一行会失败。
答案 0 :(得分:1)
如果删除AVVideoMaxKeyFrameIntervalKey
密钥会怎样?我认为你每隔60帧就会说一个关键帧。