|
@@ -29,19 +29,22 @@
|
|
|
|
|
|
NSArray *supportedFormats = device.formats;
|
|
|
|
|
|
+ CGFloat width = [UIScreen mainScreen].bounds.size.width;
|
|
|
+ CGFloat height = [UIScreen mainScreen].bounds.size.height;
|
|
|
+
|
|
|
AVCaptureDeviceFormat *bestFormat;
|
|
|
CGFloat aspect = 1;
|
|
|
//分辨率
|
|
|
CGFloat radio = 16.0/9.0;
|
|
|
if(model == SDK_CAPTURE_MODE_SINGLE || model == SDK_CAPTURE_MODE_CONTINUOUS) {
|
|
|
- radio = 4.0/3.0;
|
|
|
+ radio = height/width;
|
|
|
}
|
|
|
-
|
|
|
+ [device lockForConfiguration:nil];
|
|
|
+
|
|
|
for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
|
|
|
|
- NSLog(@"~~~~~~: H: %d, W:%D, r:%f", dimensions.width, dimensions.height, (CGFloat)dimensions.width/(CGFloat)dimensions.height);
|
|
|
-
|
|
|
+// NSLog(@"~~~~~~: H: %d, W:%D, r:%f", dimensions.width, dimensions.height, (CGFloat)dimensions.width/(CGFloat)dimensions.height);
|
|
|
|
|
|
if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio && dimensions.height == desiredHeight) {
|
|
|
bestFormat = format;
|
|
@@ -49,12 +52,11 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- [device lockForConfiguration:nil];
|
|
|
if (!bestFormat) {
|
|
|
//未找到 匹配格式 查找固定匹配格式 (720 1080 2160)
|
|
|
for (AVCaptureDeviceFormat *format in supportedFormats) {
|
|
|
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
|
|
- CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
|
+// CMVideoDimensions bestVideoDimensions = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[bestFormat formatDescription]);
|
|
|
if (((CGFloat)dimensions.width/(CGFloat)dimensions.height) == radio &&
|
|
|
(dimensions.height == 720 || dimensions.height == 1080 || dimensions.height == 2160)) {
|
|
|
// if (bestVideoDimensions.height <= dimensions.height) {
|