想做的效果跟下图的差不多,拖动进度条的时候不卡帧那种效果
到底要怎么样实现啊...我自己尝试用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
天蓬老师2017-04-18 09:23:39
Dude, have you solved it? I am also encountering this problem now, the memory is directly exploded