To save recorded video
Please can anyone provide any sample code to save video after recording. I m able to record video using UIImagePickerController.
if (canShootVideo) {
UIImagePickerController *videoRecorder = [[UIImagePickerController alloc] init];
videoRecorder.sourceType = UIImagePickerControllerSourceTypeCamera;
videoRecorder.delegate = self;
NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
NSArray *videoMediaTypesOnly = [mediaTypes filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF contains %@)", @"movie"]];
BOOL movieOutputPossible = (videoMediaTypesOnly != nil);
if (movieOutputPossib开发者_StackOverflowle) {
videoRecorder.mediaTypes = videoMediaTypesOnly;
[self presentModalViewController:videoRecorder animated:YES];
}
[videoRecorder release];
}
but how to save it. Can anyone please tell.
Thanks in advance
- (void)saveVideo:(NSURL *)videoUrl {
NSData *videoData = [NSData dataWithContentsOfURL:videoUrl];
[videoData writeToFile:@"YOUR_PATH_HERE" atomically:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *type = [mediaDict objectForKey:UIImagePickerControllerMediaType];
if ([type isEqualToString:(NSString *)kUTTypeVideo] ||
[type isEqualToString:(NSString *)kUTTypeMovie]) { // movie != video
NSURL *videoURL [mediaDict objectForKey:UIImagePickerControllerMediaURL];
[self saveVideo:videoUrl];
}
}
This is for the case you want to save the video into some file path that you can control. You can save into "Saved Photos" as well
精彩评论