Error creating video thumbnail

Here is my code for creating a video thumbnail:

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 ask me what is the mistake?

+4
source share
1 answer

If you use the video file from the kit, please follow the previous message: AVURLAsset refuses to download the video

This is a really important case.

+5
source

Source: https://habr.com/ru/post/1380707/


All Articles