gpt4 book ai didi

iphone - 保存录制的视频

转载 作者:行者123 更新时间:2023-12-03 20:16:38 31 4
gpt4 key购买 nike

请任何人提供任何示例代码来在录制后保存视频。我可以使用 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 (movieOutputPossible) {
videoRecorder.mediaTypes = videoMediaTypesOnly;

[self presentModalViewController:videoRecorder animated:YES];
}
[videoRecorder release];
}

但是如何保存它。谁能告诉一下吗?

提前致谢

最佳答案

- (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];
}

}

这适用于您想要将视频保存到您可以控制的某个文件路径的情况。您也可以保存到“已保存的照片”

关于iphone - 保存录制的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3633673/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com