AVAssetImageGenerator iOS 4.2.1错误?

时间:2011-04-12 21:12:22

标签: iphone objective-c ios

我试图从mp4视频生成图像,但在iOS iOS 4.2.1上会出现此错误

错误Domain = AVFoundationErrorDomain Code = -11800“无法完成操作。(AVFoundationErrorDomain error -11800。)”UserInfo = 0x140c00 {NSUnderlyingError = 0x13e520“操作无法完成。(OSStatus错误-12911。 )“}

它适用于iOS 4.3.1和模拟器4.2 / 4.1。

NSString *path = [[NSBundle mainBundle] pathForResource:@"evil" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];

AVAssetImageGenerator *imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset];
NSError *error = nil;
CGImageRef image = [imageGenerator copyCGImageAtTime:asset.duration actualTime:nil error:&error];
if(image == nil) {
    NSLog(@"%@", error);
}

2 个答案:

答案 0 :(得分:1)

来源很短吗?当电影的关键帧间隔比电影本身长时,我们遇到了生成缩略图的问题 - AVAssetImageGenerator似乎存在问题,它需要至少2个关键帧才能存在于文件中才能够生成图像。

答案 1 :(得分:0)

您是否检查过该文件是否存在以及您的程序是否找到该文件? 有时文件存在于项目包中,但不存在于您的文件夹中。 您可以尝试再次复制文件夹中的文件(覆盖它),然后再次将其拖放到xcode中的资源文件夹中。它对我来说也是一个类似的问题。