objective c - How to generate video thumbnail iOS without network call to server? -
i want when user pick video gallery want thumbnail image of video.so possible thumbnail image of video without uploading server?
- (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { nsurl *urlvideo = [info objectforkey:uiimagepickercontrollermediaurl]; __block nsdata *moviedata = [[nsdata alloc]initwithcontentsofurl:urlvideo];avurlasset *asset=[[avurlasset alloc] initwithurl:urlvideo options:nil]; avassetimagegenerator *generator = [[avassetimagegenerator alloc] initwithasset:asset]; generator.appliespreferredtracktransform=true; 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); } uiimage *img = [uiimage imagewithcgimage:im]; }; }
Comments
Post a Comment