我有正在开发的相机应用程序。在某些时候,我试图写视频,所以我创建了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个关键帧。

关于ios - AVAssetWriter的720p @ 60fps输出设置失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43355197/

10-08 21:46