开发者

How to record a video in iOS

Hi I would like to record a video in iPhone through Objective-C. Can someone provide me the sample code to write my own code. I have no idea how to do it. And i need it in h开发者_StackOverflowurry. Any little help will be appreciated greatly. Thanks in advance.

Regards Sohaib Qazi


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:^ {
                     }];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜