Pick video from gallery in swift

var videoPicker = UIImagePickerController()
var videoUrl : URL!
        videoPicker.delegate = self
        videoPicker.modalPresentationStyle = .currentContext
        videoPicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary)!
        videoPicker.mediaTypes = [kUTTypeMovie as String, kUTTypeAVIMovie as String, kUTTypeVideo as String, kUTTypeMPEG4 as String]
        videoPicker.videoQuality = .typeHigh
        UINavigationBar.appearance().barTintColor = APP_SOCIAL_COLOR_2
        self.present(videoPicker, animated: true, completion: nil)

UIImagePickerControllerDelegate methods

extension ViewController : UIImagePickerControllerDelegate,UINavigationControllerDelegate
{
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        
        if let videoUrl = info[UIImagePickerControllerMediaURL] as? NSURL{  
            self.videoUrl = videoUrl as URL!
        }
        dismiss(animated: true, completion: nil)
    }

 func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        dismiss(animated: true, completion: nil)
    }
}