How to change bitrate or compression rate of local video in swift
<p>I am attempting to compress a video for use in Parse in swift however I am running into the issue of the video either being 9 MB if I set the quality to AVAssetExportPresetHighQuality or too low quality with AVAssetExportPresetMediumQuality (the video is very grainy and not suitable for any consumer to actually use).  Are there any other methods to control the file size such as setting the bitrate while recording?  My compression code is below and is very basic however it creates terrible quality videos.  I would prefer to have the size of the file be around 1-3 MB and have alright quality however I cannot find any inbetween.</p>

<pre><code>func compressVideo(inputURL: NSURL, outputURL: NSURL, handler:(session: AVAssetExportSession)-&gt; Void)
{
    /*var settings: [NSObject : AnyObject] = [AVVideoCodecKey: AVVideoCodecH264, AVVideoWidthKey: 1080, AVVideoHeightKey: 1920, AVVideoCompressionPropertiesKey: [AVVideoAverageBitRateKey: 100, AVVideoProfileLevelKey: .Main31, AVVideoMaxKeyFrameIntervalKey: 30]]
    var writer_input: AVAssetWriterInput = AVAssetWriterInput.assetWriterInputWithMediaType(AVMediaTypeVideo, outputSettings: )*/

    let urlAsset = AVURLAsset(URL: inputURL, options: nil)

    let exportSession = AVAssetExportSession(asset: urlAsset, presetName: AVAssetExportPresetMediumQuality)

    exportSession!.outputURL = outputURL

    exportSession!.outputFileType = AVFileTypeQuickTimeMovie

    exportSession!.shouldOptimizeForNetworkUse = true

    exportSession!.exportAsynchronouslyWithCompletionHandler { () -&gt; Void in

        handler(session: exportSession!)
    }

}
</code></pre>