接上一篇,改做录像了,一切顺利,然后就卡在了镜像翻转上,还是那个不设限竖屏唯一的情况,找了一大堆资料都不好使,尤其有个用的writer的我的天啊.能用是能用但是好累啊!还是用movieFileOutput吧我....最后,测试成功了,步骤如下:
第一步,搞一个这个:
@property (nonatomic, strong)AVCaptureConnection *videoConnection;
第二步,搞一个这个(_movieFileOutput是啥就不用说了),注意,翻转镜头的函数中也要添加,不然发动不了videoMirrored的setter方法:
_videoConnection= [_movieFileOutput connectionWithMediaType:AVMediaTypeVideo];
第三步,在开始录制按钮方法中,在startRecordingToOutputFileURL:前搞一个这个
if (_currnetCameraDevice == _frontCameraDevice) {
if(_videoConnection.supportsVideoMirroring==YES) {
_videoConnection.videoMirrored=YES;
}
}else if (_currnetCameraDevice == _backCameraDevice) {
_videoConnection.videoMirrored=NO;
}
switch ([UIDevice currentDevice].orientation) {
case UIDeviceOrientationUnknown:
case UIDeviceOrientationFaceUp:
case UIDeviceOrientationFaceDown:
case UIDeviceOrientationPortrait:
{
_videoConnection.videoOrientation = AVCaptureVideoOrientationPortrait;
}
break;
case UIDeviceOrientationPortraitUpsideDown:
{
_videoConnection.videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
}
break;
case UIDeviceOrientationLandscapeRight:
{
_videoConnection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
}
break;
case UIDeviceOrientationLandscapeLeft:
{
_videoConnection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
}
break;
default:
break;
}
完了;
网友评论