【问题标题】:canSetSessionPreset:AVCaptureSessionPreset1920x1080 returns 'yes' on iPhone 4canSetSessionPreset:AVCaptureSessionPreset1920x1080 在 iPhone 4 上返回“是”
【发布时间】:2013-03-21 14:11:21
【问题描述】:

我想检查用户的 iPhone 是否支持全高清视频拍摄。我发现,如果

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 上也尝试设置预设,但显然失败了。我做错了什么?

提前致谢, 马蒂亚斯

【问题讨论】:

  • 这里有同样的问题。这样做: if([captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES ) { [captureSession setSessionPreset:AVCaptureSessionPreset1920x1080]; } else { [captureSession setSessionPreset:AVCaptureSessionPresetPhoto];可以在我的 iPhone 5 上运行,但在我的 iPhone 4 上运行时,它会尝试将其设置为 1929X1080,并且会话什么也不显示。如果我强制使用照片预设,那么它可以在 iPhone 4 上运行。有人吗?

标签: iphone video camera preset


【解决方案1】:

向捕获会话添加输入后是否调用了 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;
}

【讨论】:

  • 是的,这就是解决方案。暂时不能投票,声望降低:(
  • @user2228816 没关系,我的回答对您有所帮助 :) 祝您有美好的一天。
  • 你考虑接受这个答案@user2228816 吗?它有助于建立社区。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-24
  • 2011-08-17
  • 1970-01-01
  • 1970-01-01
  • 2018-09-07
相关资源
最近更新 更多