CMTimeMakeWithSeconds 中的首选时间刻度

Nik*_*ure 3 avfoundation ios cmtime swift

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

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

slider.maximumValue = Float(CMTimeGetSeconds(camera.activeFormat.maxExposureDuration))
slider.minimumValue = Float(CMTimeGetSeconds(camera.activeFormat.minExposureDuration))
Run Code Online (Sandbox Code Playgroud)

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

我的代码看起来像这样 -

change(duration: CMTimeMakeWithSeconds(Double(slider.value), 600), iso: AVCaptureISOCurrent)
Run Code Online (Sandbox Code Playgroud)

但在

func CMTimeMakeWithSeconds(_ seconds: Float64, _ preferredTimescale: Int32) -> CMTime
Run Code Online (Sandbox Code Playgroud)

我很困惑preferredTimescale,它的价值应该是多少,它与 600 一起工作正常,但什么是理想价值。

小智 5

你应该在这里查看讨论

首选时间刻度将为您的秒添加一个分母,这意味着如果您设置 5 秒和首选时间刻度为 60,它将是 1/12 秒