3

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.

Nikhil Manapure
  • 3,748
  • 2
  • 30
  • 55

1 Answers1

6

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

unkgd
  • 671
  • 3
  • 12
  • So you mean to say that it does the operation of just dividing the two values. – Nikhil Manapure Jul 28 '17 at 06:18
  • My question still remains, what should be ideal value? – Nikhil Manapure Jul 28 '17 at 06:42
  • I think that as long as your exposure is between the min and max exposure time, its a matter of just seeing what works best for you. You can check this explanation here: http://snapsnapsnap.photos/a-beginners-guide-for-manual-controls-in-iphone-photography-exposure/ It gives the the parameters for the best exposure and the relevant parameters for it – unkgd Jul 30 '17 at 06:25