我正在使用
请不要提供
谢谢。
AVCaptureVideoDataOutput
来捕获相机视频。我想裁剪CMSampleBufferRef
以使最终视频成为正方形,但我找不到解决方法。你有什么想法吗?请不要提供
AVAssetExportSession
。谢谢。
AVCaptureVideoDataOutput
来捕获相机视频。我想裁剪CMSampleBufferRef
以使最终视频成为正方形,但我找不到解决方法。你有什么想法吗?AVAssetExportSession
。暂时地,你可以尝试在类似以下的东西上设置一个字典,其中包含你的width
和height
:
NSDictionary* videoSettingsDictionary = @{
(id)kCVPixelBufferWidthKey : @(width),
(id)kCVPixelBufferHeightKey : @(height),
AVVideoScalingModeKey : AVVideoScalingModeFit
};
[yourAVCaptureVideoDataOutput setVideoSettings:videoSettingsDictionary];
AVVideoScalingModeFit
会强制AVCaptureVideoDataOutput
裁剪掉边缘处理区域,并通过减少指定的宽度或高度来保持裁剪源的纵横比。(链接到AVF文档)kCVPixelBufferPixelFormatTypeKey
这个键,但实际上也支持其他提到的键。(https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVCaptureVideoDataOutput_Class/Reference/Reference.html#//apple_ref/occ/instp/AVCaptureVideoDataOutput/videoSettings) - miguelao