CMTimeMakeWithSeconds 中的首选时间刻度

preferredTimescale in CMTimeMakeWithSeconds

我正在实现自定义相机,为此我想设置曝光持续时间。

我设置滑块属性的代码是-

slider.maximumValue = Float(CMTimeGetSeconds(camera.activeFormat.maxExposureDuration))
slider.minimumValue = Float(CMTimeGetSeconds(camera.activeFormat.minExposureDuration))

现在每当更改滑块时设置曝光时间就会出现问题。

我的代码如下所示 -

change(duration: CMTimeMakeWithSeconds(Double(slider.value), 600), iso: AVCaptureISOCurrent)

但是在

func CMTimeMakeWithSeconds(_ seconds: Float64, _ preferredTimescale: Int32) -> CMTime

我对 preferredTimescale 感到困惑,它的值应该是多少,它在 600 上工作正常,但什么是理想值。

你应该查看讨论 here

Preferred time scale 将为您的秒数添加一个分母,这意味着如果您将 preferredTimeScale 设置为 5 秒并且 preferredTimeScale 为 60,则它将是 1/12 秒