Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does AVLayerVideoGravityResizeAspectFill crop

Tags:

ios

iphone

camera

I'm using a AVCaptureSession with an AVCaptureVideoPreviewLayer with the AVLayerVideoGravityResizeAspectFill gravity.

self.captureSession =[[AVCaptureSession alloc] init];
captureSession.sessionPreset = AVCaptureSessionPresetPhoto;
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
[self.previewLayer setVideoGravity: AVLayerVideoGravityResizeAspectFill];

How to know how the video will be resized to fit the preview area with the AVLayerVideoGravityResizeAspectFill? Which part of the image is visible in the preview area?

From the doc:

AVLayerVideoGravityResizeAspectFill: This preserves the aspect ratio, but fills the available screen area, cropping the video when necessary

Basically, how to get exactly what was displayed in the previewLayer ?

like image 790
fstephany Avatar asked Nov 13 '22 16:11

fstephany


1 Answers

With the iOS 6 SDK I can use the following in AVCaptureVideoPreviewLayer

(CGPoint)captureDevicePointOfInterestForPoint:(CGPoint)pointInLayer
like image 83
fstephany Avatar answered Nov 15 '22 06:11

fstephany