문제

I am using AVCaptureVideoDataOutput to capture camera video. I would like to crop CMSampleBufferRef to make the final video square. But I can't find solution to do that. Do you have any ideas?

Please do not offer AVAssetExportSession.

Thanks.

도움이 되었습니까?

해결책

Tentatively, you could try setting a dictionary on the something like the following with your width and height:

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

Supposedly, AVVideoScalingModeFit forces the AVCaptureVideoDataOutput to Crop to remove edge processing region; preserve aspect ratio of cropped source by reducing specified width or height if necessary. (link to AVF docs)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top