How to set video capture frame rate?

有些话、适合烂在心里 提交于 2019-12-13 14:10:37

问题


So I have this basic video recording application working, but i'm wondering how I can set the frame rate (I think thats the right term) of the video capture, so when looking at the camera feed live on screen and also for that reduced capture rate to be captured when recording as well to give that slow blurry effect?

my code so far is: 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

IMPLEMENTATION:

#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

来源:https://stackoverflow.com/questions/19425429/how-to-set-video-capture-frame-rate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!