如何保存在本地文件中捕获视频

时间:2012-06-12 07:00:35

标签: iphone file video

我想用iPhone应用程序捕获视频。在这个视频文件中,我想存储本地应用程序。如何在本地保存此文件。请帮帮我。

先谢谢

1 个答案:

答案 0 :(得分:1)

你可以这样做:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{      
    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

    NSData *videoData = [NSData dataWithContentsOfURL:videoURL];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"];

    BOOL success = [videoData writeToFile:tempPath atomically:NO];


    [picker dismissModalViewControllerAnimated:YES];
}