I used the following code to record video.
UIImagePickerController *m_objpicker;=[[UIImagePickerController alloc] init];
m_objpicker.sourceType = UIImagePickerControllerSourceTypeCamera;
m_objpicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
// hide the camera controls
//picker.showsCameraControls=NO;
m_objpicker.delegate = self;
//picker.allowsImageEditing = NO;
m_objpicker.allowsEditing=NO;
// and put our overlay view in
//picker.cameraOverlayView=m_objOverlayView;
[self presentModalViewController:m_objpicker animated:YES];
When we finish recording
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSURL *m_objMediaURL=[info objectForKey:UIImagePickerControllerMediaURL];
[m_objpicker dismissModalViewControllerAnimated:YES];
}
My doubt is, how to save the captured video to a location we specify. Also how to use UISaveVideoAtPathToSavedPhotosAlbum .
What all things i need to change in my code so that i can save video to a specified location
Thanks,
If you would like to save to the Camera Roll photos/videos album on the phone:
Definition:
void UISaveVideoAtPathToSavedPhotosAlbum (
NSString *videoPath,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
Where and how to execute it:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
.... code here .....
NSString* m_objMediaURL= [info objectForKey:UIImagePickerControllerMediaURL];
//remember to test that the video is compatible for saving to the photos album
UISaveVideoAtPathToSavedPhotosAlbum(m_objMediaURL, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
.... code here .....
}
There is no control beyond saving this to the Camera Roll re: location unless you want to save to the application bundle which I do not recommend.
To the Save the Video in Photo Album:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
if (_newMedia){
if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath))
{
// Copy it to the camera roll.
UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), (__bridge void *)(tempFilePath));
}
}
-(void) video: (NSString *) videoPath
didFinishSavingWithError: (NSError *) error
contextInfo: (void *) contextInfo {
NSLog(@"Finished saving video with error: %@", error);
}
您可以将视频保存到指定的位置,请检查以下链接如何在iPhone中捕获视频
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.