How to record a video in iOS

2019-02-03 20:38发布

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 hurry. Any little help will be appreciated greatly. Thanks in advance.

Regards Sohaib Qazi

4条回答
三岁会撩人
2楼-- · 2019-02-03 21:35

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

查看更多
等我变得足够好
3楼-- · 2019-02-03 21:37
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:^ {
                     }];
}
查看更多
Melony?
4楼-- · 2019-02-03 21:39

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...

查看更多
姐就是有狂的资本
5楼-- · 2019-02-03 21:41

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

查看更多
登录 后发表回答