Swift - How to record video in MP4 format with UIImagePickerController?
<p>I am creating a app in which i need to record videos and upload it to a server. Now my project has a android version too. To support android version i have to record the videos in mp4 format. I followed <a href="http://www.deegeu.com/how-to-capture-video-in-ios-and-swift/" rel="noreferrer">this</a> tutorial to set the UIImagePicker media type to movie format <code>imagePicker.mediaTypes = [kUTTypeMovie as String]</code></p>

<p>The <code>UIImagePickerController</code> is perfect for my requirement and the only thing that i need to change is its saving format to mp4. I tried <code>kUTTypeMPEG4</code> in <code>mediaTypes</code> but it throws error at the run time with no error description. </p>

<p>This is my video Capture function</p>

<pre><code>func startCameraFromViewController() {

        if UIImagePickerController.isSourceTypeAvailable(.Camera) == false {
            return
        }
        viewBlack.hidden = false
        presentViewController(cameraController, animated: false, completion: nil)

        cameraController.sourceType = .Camera

        cameraController.mediaTypes = [kUTTypeMovie as String]
        //cameraController.mediaTypes = [kUTTypeMPEG4 as String]
        cameraController.cameraCaptureMode = .Video
        cameraController.videoQuality = .TypeMedium
        if(getPurchaseId() as! Int == 0)
        {
            if(txtBenchMark.text?.isEmpty == false)
            {
                cameraController.videoMaximumDuration = NSTimeInterval(300.0)
            }else{
                cameraController.videoMaximumDuration = NSTimeInterval(60.0)
            }
        }else{
            cameraController.videoMaximumDuration = NSTimeInterval(600.0)
        }
        cameraController.allowsEditing = false
    }
</code></pre>

<p>I am using Swift 2.2 and Xcode 8 with <code>Use Legacy swift Language version = Yes</code></p>

<p>Any Alternative Solutions are also appreciated. Thanks in advance.</p>

<p>EDIT:
I found out that there is no method to directly record videos in mp4 format in swift. only can be converted to required format from apple's quicktime mov format.</p>