9

AVCaptureVideoPreviewLayer用来传递实时视频并openGL实时应用着色器。在使用前置摄像头时,视频是镜像的,我想在应用着色器之前取消镜像它。

有人可以帮忙吗?

补充:切换到前置摄像头的代码:

-(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];
    }

}
4

1 回答 1

7

如果你已经有一个预览层,你只需要更新连接:

[[previewLayer connection] setAutomaticallyAdjustsVideoMirroring:NO];
[[previewLayer connection] setVideoMirrored:NO];
于 2014-06-26T07:51:51.527 回答