How to record a video in iOS

我只是一个虾纸丫 提交于 2019-11-30 05:33:06

AV Foundation Framework is the new way to record video and audio on iOS and Mac.

http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/00_Introduction.html#//apple_ref/doc/uid/TP40010188

It gives you much more control over focus, lighting etc...

You should typically use the highest-level abstraction available that allows you to perform the tasks you want. For example, in iOS:

  • If you simply want to play movies, you can use the Media Player Framework (MPMoviePlayerController or MPMoviePlayerViewController), or for web-based media you could use a UIWebView object.

  • To record video when you need only minimal control over format, use the UIKit framework (UIImagePickerController).

AV Foundation is one of several frameworks that you can use to play and create time-based audiovisual media. It provides an Objective-C interface you use to work on a detailed level with time-based audiovisual data. For example, you can use it to examine, create, edit, or reencode media files. You can also get input streams from devices and manipulate video during realtime capture and playback.

via - Apple

See Apple's overview of "Taking Pictures and Movies" here.

For a quick solutions, you should use UIImagePicker, which allows you to capture photos/video in your application using Apple's UI.

The Apple documentation for this class is here: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

if ([UIImagePickerController
     isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.modalTransitionStyle = UIModalPresentationFullScreen;
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.showsCameraControls = YES;
    picker.delegate = self;
    picker.mediaTypes = @[(id)kUTTypeMovie];
    [self presentViewController:picker animated:YES  // self is a viewController
                     completion:^ {
                     }];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!