我试图将整个视频转换为60fps的图像序列,这意味着每秒生成60个图像...
为此,我正在使用AVAssetImageGenerator和generateCGImagesAsynchronouslyForTimes方法......
事情进展顺利,除了我有严重的性能问题,重新规定批处理执行时间(大约5分钟,13秒视频)...
此外,在以下尺寸CGSizeMake(512,324)之上,我遇到了崩溃......
有没有人已经有过这种处理的经验,知道如何减少执行时间以及能够以更高的分辨率提取图像?
以下是我正在测试的代码......
NSURL *movieURL = [NSURL fileURLWithPath:getCaptureMoviePath()];
AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:movieURL options:nil];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generator.appliesPreferredTrackTransform=TRUE;
generator.requestedTimeToleranceAfter=kCMTimeZero;
generator.requestedTimeToleranceBefore=kCMTimeZero;
NSMutableArray *thumbTimes=[NSMutableArray arrayWithCapacity:asset.duration.value];
for(int t=0;t < asset.duration.value;t=t+2) {
CMTime thumbTime = CMTimeMake(t, asset.duration.timescale);
NSLog(@"Time Scale : %d ", asset.duration.timescale);
NSValue *v=[NSValue valueWithCMTime:thumbTime];
[thumbTimes addObject:v];
}
NSLog(@"thumbTimes array contains %d objects : ", [thumbTimes count]);
[asset release];
AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error) {
if (result != AVAssetImageGeneratorSucceeded) { …Run Code Online (Sandbox Code Playgroud) 刚安装了rmagick gem,但在尝试上传时我的控制台出现此错误:
LoadError (dlopen(/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle, 9): Library not loaded: /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libclparser.dylib
Referenced from: /usr/local/lib/libMagickCore.4.dylib
Reason: image not found - /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle):
app/uploaders/image_uploader.rb:8
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
提前致谢.