+ (uiimage*) thumbnailimageforvideo: (nsurl *) Videourl attime: (nstimeinterval) Time { Avurlasset *asset = [[Avurlasset alloc] initwithurl:videourl options: nil];
Nsparameterassert (asset);
Avassetimagegenerator *assetimagegenerator =[[avassetimagegenerator alloc] Initwithasset:asset];
Assetimagegenerator. appliespreferredtracktransform = YES;
Assetimagegenerator. Aperturemode = Avassetimagegeneratoraperturemodeencodedpixels;
Cgimageref thumbnailimageref = NULL;
Cftimeinterval thumbnailimagetime = time;
Nserror *thumbnailimagegenerationerror = nil;
Thumbnailimageref = [Assetimagegenerator copycgimageattime:cmtimemake (thumbnailimagetime, 60) Actualtime:NULL error:&thumbnailimagegenerationerror];
if (!THUMBNAILIMAGEREF)
NSLog (@ "Thumbnailimagegenerationerror%@", thumbnailimagegenerationerror);
Uiimage*thumbnailimage = Thumbnailimageref? [[UIImage Alloc]initwithcgimage: thumbnailimageref]: nil;
return thumbnailimage;
}
iOS Development videos Get the first frame picture from the URL to get any frame picture