Here is my code for generating thumbnail of video:
NSString *getUrl = [[NSUserDefaults standardUserDefaults] valueForKey:@"newpath"];
NSLog(@"getURL=%@",getUrl);
NSLog(@"newpath for url=%@",newPath);
NSURL *url = [NSURL URLWithString:getUrl];
AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:url options:nil];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generator.appliesPreferredTrackTransform=TRUE;
[asset release];
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);
}
[btnVideo setImage:[UIImage imageWithCGImage:im] forState:UIControlStateNormal];
// thumbImg=[[UIImage imageWithCGImage:im] retain];
[generator release];
};
CGSize maxSize = CGSizeMake(320, 180);
generator.maximumSize = maxSize;
[generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];
when i use this code it gives the following error:
couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x5bbbb0 {NSLocalizedFailureReason=An unknown error occurred (-12935), NSUnderlyingError=0x59ae40 "The operation couldn’t be completed. (OSStatus error -12935.)", NSLocalizedDescription=The operation could not be completed}
Can anyone suggest me what kind of error is this?
If you are using video file from bundled then please follow the previous post : AVURLAsset refuses to load video
This is really significant case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With