Iam尝试使用ios中的前置摄像头捕获视频并将其转换为图像序列,我正在尝试使用avassetimagegenerator。我刚接触AV基金会,请帮助我,谢谢。
答案 0 :(得分:0)
首先出现一个UIImagePickerController
- (void)presentVideoPicker {
UIImagePickerController *anImagePicker = [[UIImagePickerController alloc] init];
anImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
anImagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
anImagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *)kUTTypeMovie, nil];
anImagePicker.allowsEditing = YES;
anImagePicker.delegate = self;
UIPopoverController *aPopoverController = [[[UIPopoverController alloc] initWithContentViewController:anImagePicker] autorelease];
[aPopoverController presentPopoverFromRect:self.view.frame inView:[[self view] window]
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
在UIImagePickerControllerDelegate中捕获视频
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *aMediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([aMediaType isEqualToString:(NSString *)kUTTypeMovie]) {
NSURL *aVideoURL = [info objectForKey:UIImagePickerControllerMediaURL];
[self readMovie:aVideoURL];
// If you want the Duration fo the Video, Use this
AVPlayerItem *aPlayerItem = [AVPlayerItem playerItemWithURL:aVideoURL];
CMTime aDuration = aPlayerItem.duration;
float anInSeconds = CMTimeGetSeconds(aDuration);
NSInteger aDuration = nearbyintf(anInSeconds);
}
}
现在代表您在委托- (void) readMovie:(NSURL *)url
参考此链接: http://www.7twenty7.com/blog/2010/11/video-processing-with-av-foundation
...
为图像生成CVImageBuffer后,
将其转换为UIImage