title: Using AVAssetWriter to re-encode H264 mov file - how to set frame-rate?
body: <p>I'm attempting to re-encode an input MOV file with changeable frame-rate and clipped in duration, in iOS. At the moment I have an AVAssetWriter setting video properties a bit like this:</p>
  
  <pre><code>NSMutableDictionary* compressionPropertiesDict = [NSMutableDictionary new];
  compressionPropertiesDict[AVVideoProfileLevelKey] = AVVideoProfileLevelH264High40;
  
  if(self.fps &gt; 0) {
      compressionPropertiesDict[AVVideoAverageNonDroppableFrameRateKey] = [NSNumber numberWithInt:self.fps];
  
  
  _sessionMgr.videoSettings = @
  {
  AVVideoCodecKey: AVVideoCodecH264,
  AVVideoWidthKey: [NSNumber numberWithFloat:self.outputSize.width],
  AVVideoHeightKey: [NSNumber numberWithFloat:self.outputSize.height],
  AVVideoCompressionPropertiesKey: compressionPropertiesDict,
  };
  </code></pre>
  
  <p>That comes out at runtime looking like this:</p>
  
  <pre><code>videoSettings = 
  {
  AVVideoCodecKey = avc1;
  AVVideoCompressionPropertiesKey =     {
      AverageNonDroppableFrameRate = 15;
      ProfileLevel = "H264_High_4_0";
  };
  AVVideoHeightKey = 960;
  AVVideoWidthKey = 640;
  }
  </code></pre>
  
  <p>At the end of which, I get a crash with <code>NSInvalidArgumentException:
  "Compression property AverageNonDroppableFrameRate is not supported for video codec type avc1"</code>. (In unit tests using the simulator.)</p>
  
  <p>There's only one codec type that's useable in iOS, AVVideoCodecH264 / "avc1" - and I notice other projects have used the <code>AVVideoAverageNonDroppableFrameRateKey</code>. In fact, I'm using <a href="https://github.com/rs/SDAVAssetExportSession" rel="nofollow noreferrer">SDAVAssetExportSession</a> and in that codebase I see explicit use of this key. So I would have thought there must be a way to use this key to set frame-rate..?</p>
  
  <p>I've also experimented a bit using <code>AVVideoMaxKeyFrameIntervalKey</code> instead, but that doesn't change my frame-rate at all...</p>
  
  <p>So, to summarise, can anyone help me with setting a different (always lower) output frame-rate for an iOS AVFoundation-based video conversion? Thanks!</p>