我想检查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上也尝试设置预设,但显然失败了。我做错了什么?
提前致谢, 的Matthias
答案 0 :(得分:15)
在向捕获会话添加输入后,您是否调用了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;
}