UIVideoEditorController视频编辑

UIVideoEditorController类包含了由系统提供的界面,使用户可以交互式的剪切视频

  • (IBAction)click:(UIButton *)sender {
    UIImagePickerController *myImagePickerController = [[UIImagePickerController alloc] init];
    myImagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    myImagePickerController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:myImagePickerController.sourceType];
    myImagePickerController.delegate = self;
    myImagePickerController.editing = NO;
    [self presentViewController:myImagePickerController animated:YES completion:nil];
    }

pragma mark - UIImagePickerControllerDelegate

  • (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    [picker dismissViewControllerAnimated:YES completion:^{
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    if([mediaType isEqualToString:@"public.movie"]) {
    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

                  UIVideoEditorController *editVC;              
            // 检查这个视频资源能不能被修改 
                 if ([UIVideoEditorController canEditVideoAtPath:videoURL.path]) {  
                        editVC = [[UIVideoEditorController alloc] init]; 
                        editVC.videoPath = videoURL.path; editVC.delegate = self; 
                 } 
                 [self presentViewController:editVC animated:YES completion:nil];
           } 
       }];
    

}

//编辑成功后的Video被保存在沙盒的临时目录中

  • (void)videoEditorController:(UIVideoEditorController *)editor didSaveEditedVideoToPath:(NSString *)editedVideoPath {
    NSLog(@"+++++++++++++++%@",editedVideoPath);
    }

// 编辑失败后调用的方法

  • (void)videoEditorController:(UIVideoEditorController *)editor didFailWithError:(NSError *)error {
    NSLog(@"%@",error.description);
    }

//编辑取消后调用的方法

  • (void)videoEditorControllerDidCancel:(UIVideoEditorController *)editor {

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容