我遇到的問題是從視頻加載20張圖片花費的時間太長。我想要得到的縮略圖越多,我必須等待的時間越長。我使用的方法是generateCGImagesAsynchronouslyForTimes。有誰知道我爲什麼有這個問題?ios - generateCGImagesAsynchronouslyForTimes花費的時間太長
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generator.appliesPreferredTrackTransform = YES;
generator.requestedTimeToleranceAfter = kCMTimeZero;
generator.requestedTimeToleranceBefore = kCMTimeZero;
CGSize maxSize = CGSizeMake(320, 180);
generator.maximumSize = maxSize;
AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){
if (result != AVAssetImageGeneratorSucceeded) {
NSLog(@"couldn't generate thumbnail, error:%@", error);
}
UIImage *frameImage = [UIImage imageWithCGImage:im];
dispatch_async(dispatch_get_main_queue(), ^{
[_frameImageView setImage:frameImage];
});
};
[generator generateCGImagesAsynchronouslyForTimes:timeArray completionHandler:handler];
我有同樣的問題,你有任何解決方案? –
@ScorpianAlive面臨同樣的問題,您是否找到解決方案? – Sam