|
@@ -67,6 +67,14 @@
|
|
|
[super viewDidLayoutSubviews];
|
|
[super viewDidLayoutSubviews];
|
|
|
|
|
|
|
|
self.previewLayer.frame = self.previewContainer.bounds;
|
|
self.previewLayer.frame = self.previewContainer.bounds;
|
|
|
|
|
+
|
|
|
|
|
+ if (self.previewLayer.connection.isVideoOrientationSupported) {
|
|
|
|
|
+ self.previewLayer.connection.videoOrientation = [self captureVideoOrientation];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ([self.captureOutput connectionWithMediaType:AVMediaTypeVideo].isVideoOrientationSupported) {
|
|
|
|
|
+ [self.captureOutput connectionWithMediaType:AVMediaTypeVideo].videoOrientation = [self captureVideoOrientation];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Capture
|
|
#pragma mark - Capture
|
|
@@ -129,11 +137,6 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
self.captureOutput = [[AVCaptureStillImageOutput alloc] init];
|
|
self.captureOutput = [[AVCaptureStillImageOutput alloc] init];
|
|
|
- AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
|
|
|
|
|
- if (connection.supportsVideoOrientation) {
|
|
|
|
|
- connection.videoOrientation = [self.previewLayer connection].videoOrientation;
|
|
|
|
|
-// connection.videoOrientation = [self captureVideoOrientation];
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
NSDictionary *setting = @{AVVideoCodecKey:AVVideoCodecJPEG};
|
|
NSDictionary *setting = @{AVVideoCodecKey:AVVideoCodecJPEG};
|
|
|
[self.captureOutput setOutputSettings:setting];
|
|
[self.captureOutput setOutputSettings:setting];
|
|
@@ -141,7 +144,12 @@
|
|
|
if ([self.captureSession canAddOutput:self.captureOutput]) {
|
|
if ([self.captureSession canAddOutput:self.captureOutput]) {
|
|
|
[self.captureSession addOutput:self.captureOutput];
|
|
[self.captureSession addOutput:self.captureOutput];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
|
|
|
|
|
+ if (connection.isVideoOrientationSupported) { // addOutput之后判断,否则一直都是false
|
|
|
|
|
+ connection.videoOrientation = [self captureVideoOrientation];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (AVCaptureDevice *) videoDevicePosition:(AVCaptureDevicePosition)position {
|
|
- (AVCaptureDevice *) videoDevicePosition:(AVCaptureDevicePosition)position {
|