轉(zhuǎn)載:http://blog.csdn.net/enjolras1024/article/details/73471565
初始化圖片輸入和輸出源(AVCaptureDeviceInput,AVCaptureStillImageOutput)
self.deviceInput = [[AVCaptureDeviceInput alloc] initWithDevice:self.device error:&error];
self.imageOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *outputSetting = [[NSDictionary alloc] initWithObjectsAndKeys:AVVideoCodecKey, AVVideoCodecJPEG, nil];
[self.imageOutput setOutputSettings:outputSetting];
if ([self.session canAddInput:self.deviceInput]) {
[self.session addInput:self.deviceInput];
}
if ([self.session canAddOutput:self.imageOutput]) {
[self.session addOutput:self.imageOutput];
}
設(shè)置前置攝像頭拍照不鏡像
// 設(shè)置前置攝像頭拍照不鏡像
AVCaptureDevicePosition currentPosition=[[self.deviceInput device] position];
AVCaptureConnection *connection = [self.imageOutput connectionWithMediaType:AVMediaTypeVideo];
if (currentPosition == AVCaptureDevicePositionUnspecified || currentPosition == AVCaptureDevicePositionFront) {
connection.videoMirrored = YES;
} else {
connection.videoMirrored = NO;
}