当我使用 UIImagePickerController 导入 1080p 视频时,然后询问它的大小是多少,它报告它只有 720p。
这是我打开图像选择器的方法:
let picker = UIImagePickerController()
picker.sourceType = .PhotoLibrary
picker.videoQuality = .TypeHigh
picker.allowsEditing = false
picker.delegate = self
picker.modalPresentationStyle = .Popover
picker.popoverPresentationController?.sourceView = self.view
picker.popoverPresentationController?.sourceRect = self.findButton.frame
picker.mediaTypes = [kUTTypeMovie as String]
self.navigationController?.presentViewController(picker, animated: true, completion: nil)
然后,当用户选择图片时:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
let readMovieURL = info[UIImagePickerControllerMediaURL]
// ...
}
稍后我询问大小这个位在Objective-c中)
NSDictionary *options = @{AVURLAssetPreferPreciseDurationAndTimingKeyYES};
AVURLAsset *readMovieAsset = [[AVURLAsset alloc] initWithURL:readMovieURL optionsptions];
AVAssetTrack * track = [[asset tracksWithMediaType:AVMediaTypeVideo] firstObject];
// Why is it 720p?
CGSize size = track.naturalSize;
如何让用户从他们的库中选择一个 1080p 视频,然后以全分辨率使用它?
Best Answer-推荐答案 strong>
问题在于使用 UIImagePickerControllerMediaURL 。这具体是指经过处理(压缩)的视频。切换到以下为我提供了完整的 1080p 视频:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
// Reference URL instead
let readMovieURL = info[UIImagePickerControllerReferenceURL]
}
我不知道如何防止选择器首先进行压缩过程。
关于ios - 如何从 UIImagePickerController 获取 1080p 视频?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/37839314/
|