canSetSessionPreset:AVCaptureSessionPreset1920x1080 returns 'yes' on iPhone 4
Asked Answered
I

1

6

I want to check if the iPhone the user has supports full HD video capturing. I found out, that I should ask the AV session, if

avSession = [[AVCaptureSession alloc] init];
    [avSession beginConfiguration];
    if ([avSession canSetSessionPreset:AVCaptureSessionPreset1920x1080]) {
        avSession.sessionPreset = AVCaptureSessionPreset1920x1080;
        NSLog(@"FULLHD");
    } else {
        avSession.sessionPreset = AVCaptureSessionPreset1280x720;
        NSLog(@"HDREADY");
    }
    [avSession commitConfiguration];

This works fine on iPhone 5 (which indeed supports full HD capturing), but on iPhone 4 tries too to set the preset, but clearly fails. What am I doing wrong?

Thanks in advance, Matthias

Indican answered 31/3, 2013 at 8:2 Comment(1)
same problem here. Doing this: if([captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES ) { [captureSession setSessionPreset:AVCaptureSessionPreset1920x1080]; } else { [captureSession setSessionPreset:AVCaptureSessionPresetPhoto]; } works on my iPhone 5 but when run on my iPhone 4 it tries to set it to 1929X1080 and the session shows nothing. If I force the Photo preset then it works on the iPhone 4. Anybody?Devil
T
17

Did you call canSetSettingPreset after add an input to the capture session?

[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;
}
Thaw answered 5/7, 2013 at 7:53 Comment(3)
Yes, this is the solution. Can't vote up for now, to less reputation :(Indican
@user2228816 It's ok that my answer helped you :) Have a good day.Thaw
Do you consider accepting this answer @user2228816 ? It helps to build the community. :)Grimace

© 2022 - 2024 — McMap. All rights reserved.