iOS bulk capture video screenshot UIImage mp4 iOS video

Source: Internet
Author: User


iOS Batch Capture video

// Generate

NSString *path = [Nshomedirectory () stringbyappendingstring:@ "/documents"];

NSLog (@ "path%@", Path);

for (int i = 0; i<[mitems count]; i++) {

Nsmutabledictionary *info = (nsmutabledictionary *) mitems[i]; Video information

NSString *mediapath;

MediaPath = [[NSBundle mainbundle] pathforresource:[info objectforkey:@ "MediaName"]

Oftype:[info Objectforkey:@ "type"];

UIImage *image = [ self getimage:mediapath];

[UIImageJPEGRepresentation (Image, 1) Writetofile:[path stringbyappendingpathcomponent:[nsstring stringWithFormat:@ "File%d.jpg", I]] atomically:YES];

}


Gets the screenshot of the video at the specified location

-(UIImage *) GetImage: (nsstring *) videourl{

avurlasset *asset = [[avurlassetalloc] initwithurl: [ Nsurl fileurlwithpath: videourl] options:nil];

avassetimagegenerator *gen = [[avassetimagegeneratoralloc] Initwithasset : asset];

Gen. Appliespreferredtracktransform =YES;

cmtime Time =cmtimemakewithseconds(20.5,  ); The number of seconds to intercept. How many frames per second of video)

nserror *error = nil;

cmtime actualtime;

cgimageref image = [Gen copycgimageattime: Time actualtime: &actualtime Error:&error];

UIImage *thumb = [[UIImagealloc] initwithcgimage: image];

cgimagerelease(image);

return thumb;

}


iOS bulk capture video UIImage mp4 iOS videos

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.