title: Video Compression ios : Reduce the size of a video usin AVAssetWriter
body: <p>I am Successful in encoding a series of image captured by AVCaptureVideoPreviewLayer of AVFoundation Framework into a Video using AVAssetWriter and AVAssetWriterInput.</p>
  
  <p><strong>But the size of the video is too large, Can anyone of you suggest me a tutorial or atleast a direct me 
  in this case or give me the correct Video output Settings for video compression.</strong></p>
  
  <p>I am using the following VideoOutputSetting.</p>
  
  <pre><code>videoOutputSettings = @{
                            AVVideoCodecKey: AVVideoCodecH264,
                            AVVideoWidthKey: [NSNumber numberWithInt:width],
                            AVVideoHeightKey: [NSNumber numberWithInt:height],
                            AVVideoCompressionPropertiesKey: @{
                                    AVVideoAverageBitRateKey: [NSNumber numberWithInt:bitrate],
                                    AVVideoMaxKeyFrameIntervalKey: @(150),
                                    AVVideoProfileLevelKey: AVVideoProfileLevelH264BaselineAutoLevel,
                                    AVVideoAllowFrameReorderingKey: @NO,
                                    AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCAVLC,
                                    AVVideoExpectedSourceFrameRateKey: @(30),
                                    AVVideoAverageNonDroppableFrameRateKey: @(30)
                                    }
                            };
      videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];
      _videoWriterInput.expectsMediaDataInRealTime = YES;
  </code></pre>