同时在ios中单击录制按钮时捕获图像

时间:2013-05-16 11:08:18

标签: ios video uiimagepickercontroller capture

我使用UIImagePicker录制视频,当我点击录制按钮时我想用声音捕捉帧并将其添加到一个阵列中。请帮我提前完成同样的感谢。

1 个答案:

答案 0 :(得分:0)

尝试此框架

中的录制视频示例代码

customphotoalbum

修改

    - (void)video:(NSString*)videoPath didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo {
        NSLog(@"%@",contextInfo);
        if (error) {
        }else{        
            NSURL *videoURl = [NSURL fileURLWithPath:videoPath];
            AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURl options:nil];
            AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
            generate.appliesPreferredTrackTransform = YES;
            NSError *err = NULL;
            CMTime time = CMTimeMake(1, 60);// heare you can set more then one image time
            CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];

            self.strUploadVideoURL = videoPath;
            self.strOriginalVideoURL = videoPath;

            UIImage *img = [[UIImage alloc] initWithCGImage:imgRef];
             // use this image to add in array.
        }
    }