iOS设备上支持的AVCaptureSessionPreset

3

有没有一种方法可以检查iOS设备是否支持具体的AVCaptureSessionPreset?我想设置AVCaptureSession的分辨率,但是我不知道如何检查设备是否能够使用所选分辨率捕获摄像头帧。

AVCaptureSession * _session;
NSString * _sessionPreset;
_sessionPreset = AVCaptureSessionPreset1920x1080;

// Here I would like to perform a check.

[_session setSessionPreset:_sessionPreset];
1个回答

9
请使用以下内容:
if ([self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080])
    {
        self.captureSession.sessionPreset = AVCaptureSessionPreset1920x1080;
    } else if ([self.captureSession canSetSessionPreset:AVCaptureSessionPreset640x480])
        {
            NSLog(@"Set preview port to 640X480");
            self.captureSession.sessionPreset = AVCaptureSessionPreset640x480;
        }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接