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.
Asked
Active
Viewed 202 times
-1
-
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 Answers
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;

Sirajudheen Abdul Rahiman
- 185
- 1
- 11