Search code examples
iosvideoframeavplayeravplayerlayer

AVPlayer seekToTime only generates frame every second


how can I make AVPlayerLayer display the exact video's frame in method seekToTime.

Now [AVPlayer seekToTime:CMTimeMakeWithSeconds(CMTimeGetSeconds(A, B))], the AVPlayerLayer only displays the frame at every 1-second change for example 1.50-2.50-3.50. I want it to display frame at 4.45 second for example. Is it possible?


Solution

  • You can use [AVPlayer seekToTime: toleranceBefore: toleranceAfter:] to get random media access with higher precision.
    To get the highest precision possible, pass kCMTimeZero as argument for both tolerances. Note that this might add noticeable delay during seeks.