Get from the video:
NSString *movpath =[[nsbundle Mainbundle] pathforresource:@ "iosxcode4″oftype:@" mov "];
Mpviemcontroller =[[mpmovieplayerviewcontroller alloc] Initwithcontenturl:[nsurl Fileurlwithpath:movpath];
MPMoviePlayerController *mp=[mpviemcontroller MoviePlayer];
UIImage *thumbimage=[mp Thumbnailimageattime:second Timeoption:mpmovietimeoptionnearestkeyframe];
NSData *imagedata =uiimagepngrepresentation (thumbimage);
[ImageData writetofile:@ "Iosxcode4.png" atomically:yes];
The second way is to write a category directly for UIImage:
+ (UIImage *) GetImage: (NSString *) Videourl
{
Avurlasset *asset = [[Avurlasset alloc] Initwithurl:[nsurl Fileurlwithpath:videourl] 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];
Cgimagerelease (image);
return thumb;
}
iOS gets from video