在网上找了很多资料和dome都没有处理镜像的,于是就自己研究了下。在官方说明文档中找到了...哈哈官方链接
AVCaptureConnection *connection = [_videoDataOutPut connectionWithMediaType:AVMediaTypeVideo]; connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;//视频的方向 NSLog(@"%@镜像",connection.supportsVideoMirroring?@"支持":@"不支持"); connection.videoMirrored = NO;
屏幕快照 2018-08-27 下午5.27.40.png
但是需要设置connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;//视频的方向,如果不设置可能就是是上下左右镜像,设置后就是左右镜像了。具体可参考官方说明文档
当然如果你是在输出时需要的镜像那么是AVCaptureVideoDataOutput * _videoDataOutPut。
在视频开始录制打的时候进行判断是否镜像
if ( _cameraDevice.position==AVCaptureDevicePositionBack){
AVCaptureConnection *connection = [_videoDataOutPut connectionWithMediaType:AVMediaTypeVideo]; connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight; NSLog(@"%@镜像",connection.supportsVideoMirroring?@"支持":@"不支持"); connection.videoMirrored = NO; }else if(_cameraDevice.position == AVCaptureDevicePositionFront||_cameraDevice.position == AVCaptureDevicePositionUnspecified){ AVCaptureConnection *connection = [_videoDataOutPut connectionWithMediaType:AVMediaTypeVideo]; connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight; connection.videoMirrored = YES; NSLog(@"%@镜像",connection.supportsVideoMirroring?@"支持":@"不支持"); }
献上代码