iosswiftavfoundationcmtime

preferredTimescale in CMTimeMakeWithSeconds


I am implementing custom camera and for that I want to set exposure duration.

My code for setting slider's properties is-

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

Now the problem comes while setting the exposure time whenever the slider is changed.

My code for that looks like this -

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

But in

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

I am confused with preferredTimescale, and what should be its value, it's working fine with 600, but what is ideal value.


Solution

  • You should view the discussion here

    Preferred time scale will add a denominator to your seconds, meaning if you set 5 seconds and preferredTimeScale of 60 it will be 1/12 of a second