reduce video size in swift/iOS to upload to server
<p>I am picking a video from my swift iOS app using the UIImagePickerController.  I am saving this URL and now would like to convert it to data to send to my server for storage using: </p>

<pre><code>let messageVideoData = NSData(contentsOfURL: chosenVideoURL)
</code></pre>

<p>The problem is that the file size is very large.  For a 7 second video shot on my iPhone 6s the resolution is 1280, 720, the frame rate is 30 and the file size is over 4 MB.  I have noticed the same image sent with whatsapp and other chat apps is reduced to a few hundred KB.  </p>

<p>What is the best method to reduce the file size for external storage?  The video is primarily targeted for phones so reducing the resolution to 800 or less is fine.  </p>

<p>I tried setting the UIImagePickerController quality to:</p>

<pre><code>picker.videoQuality = UIImagePickerControllerQualityType.Type640x480
</code></pre>

<p>but this only reduced the file size to 3.5 MB.</p>

<p>Using:</p>

<pre><code>picker.videoQuality = UIImagePickerControllerQualityType.TypeLow
</code></pre>

<p>reduced the resolution to a value far lower than is desirable.</p>

<p>Is there another approach I should be taking to reduce my video file size for storing on my server?  </p>