I have this camera app I am developing. At some point I am trying to write to video, so I am creating an assetWriter and I have these lines:
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])
if I am recording at 1080p @30 fps this method works perfectly but if I switch to 720p @ 60 fps this last line fails.
What happens if you remove the AVVideoMaxKeyFrameIntervalKey
key? I think you're saying 1 keyframe every 60 frames with that.