Is it possible to record and save to a file by using jpeg coder with quality setting in iOS?
<p>There basically are 2 encoders that Apple provided, h264 or avc1 and jpeg.</p>

<pre><code>let settings:[String:AnyObject] = [
    AVVideoCodecKey: AVVideoCodecJPEG,
    AVVideoWidthKey: 720,
    AVVideoHeightKey: 1280,
    AVVideoQualityKey: 0.5
]
//Line below is where the compilation error happened
VideoInput = AVAssetWriterInput(mediaType: AVMediaTypeVideo, outputSettings: settings) 
VideoInput.expectsMediaDataInRealTime = true
assetWriter.addInput(VideoInput)
</code></pre>

<p>Now, if I remove the AVVideoQualityKey:0.5 from the dict, it runs perfectly. With the key? No. Compilation error with error message quoted below.</p>

<blockquote>
  <p>Output settings dictionary contains one or more invalid keys: Quality'</p>
</blockquote>

<p>When I don't have AVVideoQualityKey in the dictionary, the final movie file was encoded with mjpeg encoder. It's too large, that's why I need to set the jpeg quality key to 0.5.</p>

<p>I thought about another way to do it by processing the samplebuffer, convert them to cvpixelbuffer and encode them myself and then convert them back and write it with assetwriter. but it seems not quite efficient because I'm sure if I can use the AVVideoQualityKey, the encoding is hardware accelerated. </p>