如何捕获视频并保存到iPhone的文档目录中 [英] How to capture video and to save into documents directory of iPhone

查看:106
本文介绍了如何捕获视频并保存到iPhone的文档目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iphone4中捕获视频,并且在完成后我想存储在iPhone的文档目录中。请帮助。我能够使用
UIImagePickerController捕获视频,但无法将其保存到文档目录中。

I want to capture video in iphone4 and at completion I want to store in documents directory of iPhone.Please help .I am able to capture video using UIImagePickerController but not able to save it into documents directory.

推荐答案

如果您想使用UIImagePicker保存视频,可以通过以下方式轻松将它们保存到相册:

If you want to save videos with a UIImagePicker, you can easily save them to the Photos Album via:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info; {
  NSURL * movieURL = [[info valueForKey:UIImagePickerControllerMediaURL] retain];// Get the URL of where the movie is stored.
  UISaveVideoAtPathToSavedPhotosAlbum([movieURL path], nil, nil, nil);
}

这允许您将其保存到相册,并保留参考路径电影后来使用。我不太确定这是否是你需要的,但它确实可以让你保存电影。

This allows you to save it to the Photos Album, and keep a reference path to the movie for use later. I'm not quite sure if this is what you need, but it does allow you to save movies.

编辑:如果你真的想要要将电影保存到文档目录,只需使用上面的代码,然后更改行:

If you really want to save the Movie to documents directory, simply take the above code, and change the line:

UISaveVideoAtPathToSavedPhotosAlbum([movieURL path], nil, nil, nil);

NSData * movieData = [NSData dataWithContentsOfURL:movieURL];

这将为您提供电影的数据,并从那里,您可以将该数据写入文件目录。希望有所帮助!

This will give you the data of the movie, and from there, you can write that data to the documents directory. Hope that helps!

这篇关于如何捕获视频并保存到iPhone的文档目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆