简体   繁体   中英

Save a section of video from UIImagePickerController programmatically

I'm trying to work out how to programmatically edit the video data I get back from UIImagePickerController.

During the recording of this video I'm going to be listening out for interesting events and logging their time, then when the video is finished, I want to be able to cut out 10 second clips at these times and save them as individual videos.

You can do this with the editing controls, so I assume it is possible programmatically too.

So far I just have the code below getting the video data and I'm not sure how to proceed.

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *type = [info objectForKey:UIImagePickerControllerMediaType];

[self dismissModalViewControllerAnimated:NO]; 

if ([type isEqualToString:(NSString *)kUTTypeVideo] || 
    [type isEqualToString:(NSString *)kUTTypeMovie]) { // movie != video
    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
    NSData *videoData = [NSData dataWithContentsOfURL:videoURL];

} 

Any ideas?

You can use FFMPEG library cut video into pieces.

Perfectly for your requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM