Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while generating thumbnail of video

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?

like image 568
Developer Avatar asked Nov 11 '11 05:11

Developer


1 Answers

If you are using video file from bundled then please follow the previous post : AVURLAsset refuses to load video

This is really significant case.

like image 162
DShah Avatar answered Oct 12 '22 09:10

DShah