我使用以下代码录制视频。
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];
当我们完成录制时
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSURL *m_objMediaURL=[info objectForKey:UIImagePickerControllerMediaURL];
[m_objpicker dismissModalViewControllerAnimated:YES];
}
我的疑问是,如何将捕获的视频保存到我们指定的位置。另外如何使用 UISaveVideoAtPathToSavedPhotosAlbum。
我需要在代码中更改所有内容,以便将视频保存到指定位置
谢谢,
答案 0 :(得分:1)
如果您想保存到手机上的相机胶卷照片/视频相册:
定义:
void UISaveVideoAtPathToSavedPhotosAlbum (
NSString *videoPath,
id completionTarget,
SEL completionSelector,
void *contextInfo
);
执行地点和方式:
- (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 .....
}
除非您想要保存到我不推荐的应用程序包中,否则除了将其保存到相机胶卷re:location之外无法控制。
答案 1 :(得分:0)
您可以将视频保存到您指定的位置,请查看以下链接how to capture video in iphone
答案 2 :(得分:0)
以相册形式保存视频:
-(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);
}