我正在开发适用于 IOS (13) 的相机应用程序。为此,我将 AVCaptureSession 与 AVCaptureVideoPreviewLayer 结合使用。到目前为止一切正常。
现在我想让用户从给定的典型快门速度值数组(以 1/3 曝光停止)中选择并设置自定义快门速度(曝光持续时间)作为 [Int32]:
let shutterSpeedValues: [Int32] = [1, 2, 3, 4, 5, 6, 8, 10, 13, 15, 20, 25, 30, 40, 50, 60, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, 10000, 12800, 16000, 20000, 2400]
据我所知,我设置所需的曝光是唯一可能的方法,具有以下功能:
captureDevice?.setExposureModeCustom(duration: CMTimeMake(value: 1, timescale: shutterSpeedValues[index]), iso: AVCaptureDevice.currentISO, completionHandler: nil)
检查 AVCaptureDevice 的 ExposureDuration 值表明,对于较慢的快门速度(高达 1/200 秒),这可以提供完全准确的结果。选择的曝光时间越快,差异就会呈指数级增长。例如。:
1/250th -> 1/251th
1/400th -> 1/403th
1/640th -> 1/648th
1/1000th -> 1/1021th
1/4000th -> 1/4366th
1/8000th -> 1/9615th
1/1200th -> 1/16129th
1/16000th -> 1/24390th
1/20000th -> 1/24390th
1/24000th -> 1/49999th (which is the activeFormat's minExposureDuration in this case)
我知道标称快门速度(对用户来说更方便的四舍五入的近似数字)和相机使用的精确实际快门速度之间存在差异(请参阅https://www.scantips.com/lights/fstop2.html https://www.scantips.com/lights/fstop2.html)。后者之间的差异恰好是相邻光阑曝光量的 2 倍或 1/2(其值为 1/2、1/4、1/8、1/16、1/32、1/64) 、1/128、1/256、1/512、1/1024、...、1/4096、...、1/8192...)。然而,这仍然无法解释我在更快的快门速度下得到的这些极端差异。
我还尝试像这样明确设置(随机)快速快门速度:
captureDevice?.setExposureModeCustom(duration: CMTimeMake(value: 1, timescale: 10000, iso: AVCaptureDevice.currentISO, completionHandler: nil)
or this
captureDevice?.setExposureModeCustom(duration: CMTimeMakeWithSeconds(0.0001, preferredTimescale: 1000000000), iso: AVCaptureDevice.currentISO, completionHandler: nil)
但两者仍然导致曝光持续时间为 1/12048(而不是 1/10000)...
我是否缺少 CMTime 相关的内容,这是否与视频的帧速率有关(尽管更改 captureDevice 的 activeVideoMinFrameDuration 和 activeVideoMaxFrameDuration 没有任何效果),还是根本不可能设置完全自定义的曝光持续时间?
顺便提一句。我在尝试实现一个允许用户在(连续)自动曝光模式下定义最小快门速度的功能时遇到了同样的问题(为此我使用了 captureDevice 的 activeMaxExposureDuration 函数)...
任何想法或提示将不胜感激。