-1

I have a video in gallery. on clicking it tries to open,but instead of that i want to show a thumbnail of video in uiimageview.

vinoad vinu
  • 225
  • 1
  • 2
  • 8
  • possible duplicate of [Getting thumbnail from a video url or data in IPhone SDK](http://stackoverflow.com/questions/1347562/getting-thumbnail-from-a-video-url-or-data-in-iphone-sdk) – Kampai Oct 16 '14 at 12:07
  • Go through this link http://stackoverflow.com/questions/9145968/getting-video-snapshot-for-thumbnail – Ramesh Muthe Oct 16 '14 at 12:09

1 Answers1

0
AVURLAsset *asset;
if ([url isFileURL]) {
   asset = [[AVURLAsset alloc] initWithURL:url options:nil];
}
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
gen.appliesPreferredTrackTransform = YES;
CMTime time = CMTimeMakeWithSeconds(0.0, 600);
NSError *error = nil;
CMTime actualTime;

CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
UIImage *finalThumpnailImage = [HPLUtility createThumpnailImageFromTheImage:thumb]; //Resized image.
CGImageRelease(image);
return finalThumpnailImage;