AVCaptureSession - output in landscape and portrait is causing problems

Closed - This job posting has been filled and work has been completed.

Job Description


I have an iPhone app that captures video and shows it using AVCaptureSession. But when I rotate it in captureOutput delegate, it seems a bit squished.

I need some help with this app on Skype, but I can't share all the code. If you have used AVCapture help should be a breeze.


- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];
AVCaptureVideoOrientation orientation = UIImageOrientationRight;

if (deviceOrientation == UIDeviceOrientationLandscapeLeft)
orientation = UIImageOrientationUp;
else if (deviceOrientation == UIDeviceOrientationLandscapeRight)
orientation = UIImageOrientationDown;

CVPixelBufferRef pixel_buffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixel_buffer];

CGImageRef ref = [self.context createCGImage:ciImage fromRect:ciImage.extent];
UIImage *image = [UIImage imageWithCGImage:ref scale:1.0 orientation:orientation];


// add frames to array if supposed to be captured
if (captureFrames == TRUE)
[self.imageFrames addObject:image];
if (self.imageFrames.count > 10)
captureFrames = FALSE;
NSLog(@"capturing frame");

// Show image
[self.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES];

Skills: video

Other open jobs by this client