gpt4 book ai didi

ios - 如何从 UIImagePickerController 获取最长持续时间的视频

转载 作者:行者123 更新时间:2023-11-29 05:41:29 26 4
gpt4 key购买 nike

我在我的应用程序中实现了一个 UIImagePickerController,其 videoMaximumDuration 为 10 秒。

但是,在 NSDictionary 中的委托(delegate) imagePickerController:didFinishPickingMediaWithInfo: 的回调中,我只能从 PHAsset 中检索原始视频(而不是修剪后的视频)。

当我选择视频时从字典中获取 NSLog。

info: {
UIImagePickerControllerMediaType = "public.movie";
UIImagePickerControllerPHAsset = "<PHAsset: 0x1149af010> E2FA31C6-0232-4A89-8DE5-A4C8CBC98D97/L0/001 mediaType=2/0, sourceType=1, (540x960), creationDate=2019-06-05 14:01:07 +0000, location=0, hidden=0, favorite=0 ";
UIImagePickerControllerReferenceURL = "assets-library://asset/asset.mov?id=E2FA31C6-0232-4A89-8DE5-A4C8CBC98D97&ext=mov";
}
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];

if([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
picker.delegate = self;
picker.allowsEditing = YES;
picker.videoMaximumDuration = 10.0f;
picker.modalPresentationStyle = UIModalPresentationCurrentContext;
picker.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4, (NSString*)kUTTypeImage];
picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

[self._viewCtrl presentViewController:picker animated:YES completion:nil];
}

如何访问剪辑后的视频?谢谢

最佳答案

我不知道为什么,但通过 UIImagePickerControllerSourceTypePhotoLibrary 更改 UIImagePickerControllerSourceTypeSavedPhotosAlbum 修复了它(现在在 NSSDictionary 中显示 UIImagePickerControllerMediaURL)

关于ios - 如何从 UIImagePickerController 获取最长持续时间的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56508858/

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