我想检查用户的iPhone是否支持全高清视频拍摄。我发现,我应该问AV会话,如果
avSession = [[AVCaptureSession alloc] init];
[avSession beginConfiguration];
if ([avSession canSetSessionPreset:AVCaptureSessionPreset1920x1080]) {
avSession.sessionPreset = AVCaptureSessionPreset1920x1080;
NSLog(@"FULLHD");
} else {
avSession.sessionPreset = AVCaptureSessionPreset1280x720;
NSLog(@"HDREADY");
}
[avSession commitConfiguration];
这在iPhone 5上工作得很好(它确实支持全高清拍摄),但在iPhone 4上也尝试设置预设,但显然失败了。我做错了什么?
提前感谢,马提亚
是否在添加输入到捕获会话后调用canSetSettingPreset ?
[captureSession addInput:captureInput]; // <--- you should add an input before canSetSessionPreset
[captureSession addOutput:captureOutput];
if( [captureSession canSetSessionPreset:AVCaptureSessionPreset1280x720] == YES ) {
captureSession.sessionPreset = AVCaptureSessionPresetiFrame1280x720;
} else {
captureSession.sessionPreset = AVCaptureSessionPreset640x480;
}