How do I control AVAssetWriter to write at the correct FPS

后端 未结 2 1963
孤街浪徒
孤街浪徒 2020-12-10 05:02

Let me see if I understood it correctly.

At the present most advanced hardware, iOS allows me to record at the following fps: 30, 60, 120 and 240.

But these

2条回答
  •  感动是毒
    2020-12-10 05:44

    The iOS screen refresh is locked at 60fps, so the only way to "see" the extra frames is, as you say, to slow down the playback rate, a.k.a slow motion.

    So

    1. yes, you are right
    2. the screen refresh rate (and perhaps limitations of the human visual system, assuming you're human?) means that you cannot perceive 120 & 240fps frame rates. You can play them at normal speed by downsampling to the screen refresh rate. Surely this is what AVPlayer already does, although I'm not sure if that's the answer you're looking for.
    3. you control the framerate of the file when you write it with the CMSampleBuffer presentation timestamps. If your frames are coming from the camera, you're probably passing the timestamps straight through, in which case check that you really are getting the framerate you asked for (a log statement in your capture callback should be enough to verify this). If you're procedurally creating frames, then you choose the presentation timestamps so that they're spaced 1.0/desiredFrameRate seconds apart!

    Is 3. not working for you?

    p.s. you can discard & ignore AVVideoMaxKeyFrameIntervalKey - it's a quality setting and has nothing to do with playback framerate.

提交回复
热议问题