Record video in swift.

var videoPicker = UIImagePickerController()
var videoUrl : URL!

open default iPhone camera for record video in swift

        videoPicker.delegate = self
        videoPicker.sourceType = UIImagePickerControllerSourceType.camera
        videoPicker.allowsEditing = false
        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)
    }
}