I am using UIImagePickerController and I want to reduce the file size of the video imported but quality still good:
I am using the following code:
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)
{
}
}
The code above compresses the video and the video loses its quality. How do I compress the video same like WhatsApp does and still maintain the quality?
I went through this answer at: iPhone:Programmatically compressing recorded video to share? but it is for Objective C and I am unable to figure out a Swift version for this. It will very helpful if someone could help me with a Swift version for this.