User response692178 is working. But a cleaner approach would be to set the kCVPixelBufferWidthKey and kCVPixelBufferHeightKey to an AVCaptureVideoDataOutput object. Then there is no need to get exclusive access to the device by calling AVCaptureDevice lockForConfigration before starting AVCaptureSession . Minimum sample as shown below.
_session = [[AVCaptureSession alloc] init]; _sessionInput = [AVCaptureDeviceInput deviceInputWithDevice:_device error:&error]; _sessionOutput = [[AVCaptureVideoDataOutput alloc] init]; NSDictionary *pixelBufferOptions = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithDouble:width], (id)kCVPixelBufferWidthKey, [NSNumber numberWithDouble:height], (id)kCVPixelBufferHeightKey, [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil]; [_sessionOutput setVideoSettings:pixelBufferOptions];
Note. This width / height overrides the width / height of the session preset (if different).
Kiran
source share