The AVCaptureVideoPreviewLayer front camera is flipped (unmirror) with a pixel buffer before moving on to opengl shader

I use AVCaptureVideoPreviewLayer to transmit live video and use openGL shaders in real time. When using the front camera, the mirror is reflected, I want to cancel the mirror before applying the shader.

Can anyone help?

Added: code for switching to the front camera:

 -(void)showFrontCamera{ NSLog(@"inside showFrontCamera"); [captureSession removeInput:videoInput]; // Grab the front-facing camera AVCaptureDevice *backFacingCamera = nil; NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; for (AVCaptureDevice *device in devices) { if ([device position] == AVCaptureDevicePositionFront) { backFacingCamera = device; } } // Add the video input NSError *error = nil; videoInput = [[[AVCaptureDeviceInput alloc] initWithDevice:backFacingCamera error:&error] autorelease]; if ([captureSession canAddInput:videoInput]) { [captureSession addInput:videoInput]; } } 
+7
source share
1 answer

If you already have a preview layer, you just need to update the connection:

 [[previewLayer connection] setAutomaticallyAdjustsVideoMirroring:NO]; [[previewLayer connection] setVideoMirrored:NO]; 
+4
source

All Articles