AVAssetWriter 输出设置失败,720p @ 60fps
AVAssetWriter failing output settings with 720p @ 60fps
我正在开发这个相机应用程序。在某些时候我正在尝试写入视频,所以我正在创建一个 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,最后一行将失败。
如果删除 AVVideoMaxKeyFrameIntervalKey
键会怎样?我想你说的是每 60 帧 1 个关键帧。
我正在开发这个相机应用程序。在某些时候我正在尝试写入视频,所以我正在创建一个 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,最后一行将失败。
如果删除 AVVideoMaxKeyFrameIntervalKey
键会怎样?我想你说的是每 60 帧 1 个关键帧。