2011-08-12 14 views
0

我想從電影中獲取一些圖像並製作一個gif。我所做的是用一個imagePickerController拿一部電影,然後我用AVAssetImageGenerator獲取圖像時使用的問題generateCGImagesAsynchronouslyForTimes

- (void)generateCGImagesAsynchronouslyForTimes:(NSArray *)requestedTimes completionHandler:(AVAssetImageGeneratorCompletionHandler)handler; 

來生成圖像。我確實得到了圖像,但圖像的時間不是我想要的。

請求:{0/600 = 0.000,圓形},得到:{0/600 = 0.000}

請求:{六百分之一百一= 0.183,圓形},得到:{0/600 = 0.000}

請求:{600分之221= 0.368,圓形},得到:{0/600 = 0.000}

請求:{600分之331= 0.552,圓形},得到:{六百分之六百○一= 1.002}

要求:{442/600 = 0.737,四捨五入},得到:{601/600 = 1.002}

請求:{600分之552= 0.920,圓形},得到:{六百分之六百○一= 1.002}

請求:{600分之663= 1.105,圓形},得到:{六百分之六百○一= 1.002}

請求:{600分之773= 1.288,圓形},得到:{六百分之六百○一= 1.002}

請求:{600分之884= 1.473,圓形},得到:{六百分之六百○一= 1.002}

正如你所看到的,時間都被四捨五入爲整數,是否有任何獲得電影的第二個圖像?

對不起我的英文不好! 希望任何人都可以幫助我,謝謝!

回答

2

找到答案在AVAssetImageGenerator Class Reference

設置的requestedTimeToleranceBeforerequestedTimeToleranceAfter值以kCMTimeZero請求幀精確圖像生成;這可能會導致額外的解碼延遲。

下面是我使用的代碼:

imageGenerator.requestedTimeToleranceAfter = kCMTimeZero; 
imageGenerator.requestedTimeToleranceBefore = kCMTimeZero; 
+0

就是這樣。非常感謝你。 – tctony

相關問題