想做的效果跟下图的差不多,拖动进度条的时候不卡帧那种效果
到底要怎么样实现啊...我自己尝试用AVAssetImageGenerator这个把帧图片取出来,可是太耗内存了。。超过10秒的视频程序就崩
我把视频帧率都取出来了,可视频超过10秒的话就程序就崩了
//取出帧图片
[imgGenerator generateCGImagesAsynchronouslyForTimes:times completionHandler:^(CMTime requestedTime, CGImageRef _Nullable image, CMTime actualTime, AVAssetImageGeneratorResult result, NSError * _Nullable error) {
printf("current-----: %lld\n", requestedTime.value);
switch (result) {
case AVAssetImageGeneratorCancelled://取消
NSLog(@"Cancelled");
break;
case AVAssetImageGeneratorFailed://失败
NSLog(@"Failed");
break;
case AVAssetImageGeneratorSucceeded: {//成功
NSString *filePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"/%lld.png",requestedTime.value]];
UIImage *uImage = [UIImage imageWithCGImage:image];
NSData *imgData = UIImagePNGRepresentation(uImage);
[imgData writeToFile:filePath atomically:YES];
uImage = nil;
if (requestedTime.value == timesCount) {
NSLog(@"completed");
if (completedBlock) {
//回调
completedBlock(path,timesCount);
}
}
}
break;
}
}];
求求大家能帮帮忙解决解决T.T
哥們 解決了嗎?我現在也遇到這個問題,,記憶體直接爆了
https://github.com/foxling/AV...