Reputation: 292
Im trying to generate an image from an mp4 video but it will fail on iPhone iOS 4.2.1 with this error
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation couldn’t be completed. (AVFoundationErrorDomain error -11800.)" UserInfo=0x140c00 {NSUnderlyingError=0x13e520 "The operation couldn’t be completed. (OSStatus error -12911.)"}
It works just fine on iOS 4.3.1 and simulator 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);
}
Upvotes: 1
Views: 1398
Reputation: 3674
Is the source very short? We had a problem with generating thumbnails when the movie's keyframe interval was longer than the movie itself -- there seems to be an issue with the AVAssetImageGenerator
where it needs at least 2 keyframes to be present in the file to be able to generate an image.
Upvotes: 1
Reputation: 1330
Have you checked that the file exists and that your program finds it? Sometimes the files exists in your project bundle, but not in your folder. you can try to copy the file in your folder again (overwrite it), and then drag it again in your resource folder in xcode. It worked for me for a similar problem.
Upvotes: 0