3

所以我有这个基本的视频录制应用程序工作,但我想知道如何设置视频捕获的帧速率(我认为这是正确的术语),所以当在屏幕上实时查看相机馈送时,也为了减少录制时要捕获的捕获率以及提供缓慢的模糊效果?

到目前为止我的代码是:HEADER

//  ViewController.h
//  VideoTest  
//
// 

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import <MobileCoreServices/MobileCoreServices.h>

@interface ViewController : UIViewController <UIImagePickerControllerDelegate,  UINavigationControllerDelegate>

@property (copy,   nonatomic) NSURL *movieURL;
@property (strong, nonatomic) MPMoviePlayerController *movieController;

- (IBAction)takeVideo:(UIButton *)sender;
@end

执行:

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
//    Check if the unit has a camera
if (![UIImagePickerController     isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

    UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Oops"
                                                          message:@"Sorry but this device  has no camera."
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles: nil];

    [myAlertView show];

}else{
[super viewDidLoad];
}

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//  Capture Video Action
- (IBAction)takeVideo:(UIButton *)sender {

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];

[self presentViewController:picker animated:YES completion:NULL];

 }

- (void)imagePickerController:(UIImagePickerController *)picker  didFinishPickingMediaWithInfo:(NSDictionary *)info {

self.movieURL = info[UIImagePickerControllerMediaURL];

[picker dismissViewControllerAnimated:YES completion:NULL];

}
//  Recording Cancelled
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:NULL];

}

- (void)viewDidAppear:(BOOL)animated {

self.movieController = [[MPMoviePlayerController alloc] init];

[self.movieController setContentURL:self.movieURL];
[self.movieController.view setFrame:CGRectMake (0, 0, 320, 476)];
[self.view addSubview:self.movieController.view];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                               name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:self.movieController];



[self.movieController play];

}
//  Playback ended

- (void)moviePlayBackDidFinish:(NSNotification *)notification {

[[NSNotificationCenter defaultCenter]removeObserver:self  name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

[self.movieController stop];
[self.movieController.view removeFromSuperview];
self.movieController = nil;

}

@end
4

0 回答 0