在iPhone中捕获视频和图像

| 我正在使用ImagePickerController进行视频捕获。我还需要将捕获的视频另存为图像。 因此,我选择了AVCaptureSession来捕获图像。我无法运行AVCaptureSession和ImagePickerController。因此,我需要将ImagePickerController作为AVCaptureSession的输入。 但是我不知道该怎么做。请帮助我..并以正确的方式建议我。     
已邀请:
我只发现了这两个。希望能有所帮助。 http://www.iphonedevsdk.com/forum/iphone-sdk-development/24025-uiimagepickercontroller-videorecording-iphone-3gs.html UIImagePickerController:从视频获取图像捕获     
我遇到了同样的问题。.我确实研究了图像和视频,并使用以下代码进行图像捕获:
- (void) snapImage: (id) sendern
{
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
    ipc.sourceType =  UIImagePickerControllerSourceTypeCamera;
    ipc.delegate = self;
    ipc.allowsImageEditing = YES;
    [self presentModalViewController:ipc animated:YES]; 

}
对于视频录制,我使用以下代码:
- (void) recordVideo: (id) sender
{
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
    ipc.sourceType =  UIImagePickerControllerSourceTypeCamera;
    ipc.delegate = self;
    ipc.allowsEditing = YES;
    ipc.videoQuality = UIImagePickerControllerQualityTypeMedium;
    ipc.videoMaximumDuration = 30.0f; // 30 seconds
    ipc.mediaTypes = [NSArray arrayWithObject:@\"public.movie\"];
    // ipc.mediaTypes = [NSArray arrayWithObjects:@\"public.movie\", @\"public.image\", nil];
    [self presentModalViewController:ipc animated:YES]; 
}
希望能对您的代码片段有所帮助。     
    - (IBAction) useCamera: (id)sender
    {
        if ([UIImagePickerController isSourceTypeAvailable:
             UIImagePickerControllerSourceTypeCamera])
        {
            UIImagePickerController *imagePicker =
            [[UIImagePickerController alloc] init];
            imagePicker.delegate = self;
            imagePicker.sourceType =
            UIImagePickerControllerSourceTypeCamera;
            imagePicker.mediaTypes = [NSArray arrayWithObjects:
                                      (NSString *) kUTTypeImage,
                                      nil];
            imagePicker.allowsEditing = NO;
            [self presentModalViewController:imagePicker
                                    animated:YES];
            newMedia = YES;
        }
    }

-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self.popoverController dismissPopoverAnimated:true];

    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    [self dismissModalViewControllerAnimated:YES];
    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) 
    {
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    imageView.image = image;
        if (newMedia)
            UIImageWriteToSavedPhotosAlbum(image, self,  
                                           @selector(image:finishedSavingWithError:contextInfo:),nil);
    }

}
-(void)image:(UIImage *)image
finishedSavingWithError:(NSError *)error
 contextInfo:(void *)contextInfo
{
    if (error) 
    {
        UIAlertView *alert = [[UIAlertView alloc]
                              initWithTitle: @\"Save failed\"
                              message: @\"Failed to save image\"
                              delegate: self
                              cancelButtonTitle:@\"OK\"
                              otherButtonTitles:nil];
        [alert show];

    }
}
    
与AVFoundation相关的Apple文档和示例代码有几个错误。请参阅iOS 4:使用AVFoundation使用实时预览拍摄照片,以获取实际捕获来自实时预览的图像的代码。     

要回复问题请先登录注册