【问题标题】:Crop CMSampleBufferRef samples裁剪 CMSampleBufferRef 样本
【发布时间】:2014-03-26 10:38:09
【问题描述】:

我正在使用AVCaptureVideoDataOutput 来捕捉摄像头视频。我想裁剪CMSampleBufferRef 来制作最终的视频正方形。但我找不到解决方案来做到这一点。你有什么想法吗?

请不要提供AVAssetExportSession

谢谢。

【问题讨论】:

  • 你可以使用 CoreImage 过滤它,利用 ciimages initWithCVImageBuffer:

标签: ios iphone video-processing


【解决方案1】:

暂时,您可以尝试使用widthheight 设置字典,如下所示:

NSDictionary* videoSettingsDictionary = @{
    (id)kCVPixelBufferWidthKey : @(width),
    (id)kCVPixelBufferHeightKey : @(height),
    AVVideoScalingModeKey : AVVideoScalingModeFit
};
[yourAVCaptureVideoDataOutput setVideoSettings:videoSettingsDictionary];

据推测,AVVideoScalingModeFitAVCaptureVideoDataOutput 强制为Crop to remove edge processing region; preserve aspect ratio of cropped source by reducing specified width or height if necessary. (link to AVF docs)

【讨论】:

  • 有趣的是,文档说只支持密钥kCVPixelBufferPixelFormatTypeKey,但提到的那些也受到尊重。 (developer.apple.com/library/ios/documentation/AVFoundation/…)
  • 可悲的是,这似乎不再有效。尝试使用给定键设置视频设置字典会打印 videoSettings dictionary contains one or more unsupported (ignored) keys: (AVVideoScalingModeKey, Height, Width)
  • 还有其他解决方案吗?我卡住了...谢谢
猜你喜欢
  • 1970-01-01
  • 2012-05-15
  • 2011-03-24
  • 1970-01-01
  • 2015-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多