我正在使用UIImagePickerController,我想减小导入的视频的文件大小,但质量仍然不错:
我正在使用以下代码:
func addAttachmentUtil(from : String)
{
let file = UIImagePickerController()
file.delegate = self
file.sourceType = UIImagePickerControllerSourceType.photoLibrary
file.videoMaximumDuration = 600
file.mediaTypes = ["public.image", "public.movie"]
file.videoQuality = .type640x480
file.allowsEditing = false
self.present(file, animated: true)
{
}
}
上面的代码压缩视频,视频质量下降。如何像WhatsApp一样压缩视频并仍然保持质量?
我在iPhone:Programmatically compressing recorded video to share?处找到了这个答案,但这是针对Objective C的,我无法为此找到一个Swift版本。如果有人可以为此提供Swift版本,这将非常有帮助。