如何从最长持续时间的 UIImagePickerController 获取视频
How to get video from UIImagePickerController with maximum duration
我在我的应用程序中实现了一个 UIImagePickerController,其 videoMaximumDuration 为 10 秒。
但是在来自委托的回调中 imagePickerController:didFinishPickingMediaWithInfo:在 NSDictionary 中,我只能从 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];
}
我如何访问修剪后的视频?
感谢
我不知道为什么,但将 UIImagePickerControllerSourceTypeSavedPhotosAlbum
更改为 UIImagePickerControllerSourceTypePhotoLibrary
修复了它(现在在 NSSDictionary 中显示 UIImagePickerControllerMediaURL
)
我在我的应用程序中实现了一个 UIImagePickerController,其 videoMaximumDuration 为 10 秒。
但是在来自委托的回调中 imagePickerController:didFinishPickingMediaWithInfo:在 NSDictionary 中,我只能从 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];
}
我如何访问修剪后的视频? 感谢
我不知道为什么,但将 UIImagePickerControllerSourceTypeSavedPhotosAlbum
更改为 UIImagePickerControllerSourceTypePhotoLibrary
修复了它(现在在 NSSDictionary 中显示 UIImagePickerControllerMediaURL
)