我正在尝试使用 AVFoundation Framework 创建视频缩略图。我已正确添加并导入#import <AVFoundation/AVFoundation.
以下是创建缩略图的代码:
AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:[NSURL URLWithString:moviePath] options:nil];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generator.appliesPreferredTrackTransform=TRUE;
CMTime thumbTime = CMTimeMakeWithSeconds(0,30);
AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){
if (result != AVAssetImageGeneratorSucceeded) {
NSLog(@"couldn't generate thumbnail, error:%@", error);
}
[imageButton setImage:[UIImage imageWithCGImage:im] forState:UIControlStateNormal];
//UIImage *thumbImg=[UIImage imageWithCGImage:im];
};
CGSize maxSize = CGSizeMake(320, 180);
generator.maximumSize = maxSize;
[generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];
当我构建它时,我收到以下错误:
Undefined symbols for architecture i386:_CMTimeMakeWithSeconds", referenced from:
-[photojournal generateImage] in photojournal.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
我已经在 Google 和 Stack Overflow 上查看了类似的问题,共识似乎是添加丢失的文件来编译源代码。我的问题是 - AVFoundation 缺少哪些文件?当我导入框架时,它们不应该都来吗?谢谢。