2014-02-18 43 views
3

如何讓AVPlayerLayer在方法seekToTime中顯示確切的視頻幀。AVPlayer seekToTime每秒只產生一幀

現在[AVPlayer seekToTime:CMTimeMakeWithSeconds(CMTimeGetSeconds(A, B))]AVPlayerLayer只顯示框架在每1秒更改例如1.50-2.50-3.50。例如,我希望它在4.45秒時顯示幀。可能嗎?

回答

7

您可以使用[AVPlayer seekToTime: toleranceBefore: toleranceAfter:]獲得更高精度的隨機媒體訪問。
要獲得儘可能高的精度,請將kCMTimeZero作爲兩個公差的參數。請注意,這可能會在搜索過程中增加明顯的延遲。

+0

轉發視頻沒有延遲,但後退。我如何防止它? –

+1

你不能。更高的精度需要更多的合成操作。 seekToTime:方法還提供了帶有完成處理程序的變體。您可以使用基於搜索的完成處理程序來使您的應用程序響應更快。這些方法還具有先前的查找請求被取消的優點。 https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayer_Class/Chapters/Reference.html#//apple_ref/occ/instm/AVPlayer/seekToTime:toleranceBefore:toleranceAfter:completionHandler: –

+0

是的!你有什麼想法如何Instagram和內置照片應用程序做視頻倒帶如此順利。 –