title: kCMSampleBufferAttachmentKey_TrimDurationAtStart error
body: <p>Getting an error when trying to convert a video recorded from camera or picked from gallery:
  <strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[AVAssetWriterInput appendSampleBuffer:] 
  Cannot append sample buffer: First input buffer must have an appropriate kCMSampleBufferAttachmentKey_TrimDurationAtStart since the codec has encoder delay'`</p>
  
  <p>This is discussed here: <a href="https://stackoverflow.com/questions/35425951/cmsamplebufferref-kcmsamplebufferattachmentkey-trimdurationatstart-crash">CMSampleBufferRef kCMSampleBufferAttachmentKey_TrimDurationAtStart crash</a></p>
  
  <p>But no resolution was reached.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>[self.audioInput requestMediaDataWhenReadyOnQueue:self.audioQueue usingBlock:^{
          CMSampleBufferRef buffer;
          LIMTAssetFileWriter * __strong strongSelf = weakSelf;
          while (strongSelf.audioInput.isReadyForMoreMediaData) {
              LIMTPayload *payload = [strongSelf.cache dequeuePayloadForType:LIMTPayloadTypeAudio];
              buffer = payload.getCMSampleBuffer;
              if (buffer) {
                  if (!strongSelf.sessionStarted) {
                      [strongSelf.assetWriter startSessionAtSourceTime:CMSampleBufferGetPresentationTimeStamp(buffer)];
                      strongSelf.sessionStarted = YES;
                  }
                  [strongSelf.audioInput appendSampleBuffer:buffer];
                  [LIMTLogger.sharedLogger logInfo:@"Audio buffer appended"];
                  CFRelease(buffer);
                  buffer = NULL;
              } else if ([strongSelf.cache statusForType:kCMMediaType_Audio] == LIMTCacheStatusCompleted) {
                  [strongSelf.audioInput markAsFinished];
                  [LIMTLogger.sharedLogger logInfo:@"Audio complete"];
                  dispatch_group_leave(strongSelf.dispatchGroup);
                  break;
              } else {
                  break;
              }
          }
      }];
  </code></pre>
  
  <p>Error is happening here: <code>[strongSelf.audioInput appendSampleBuffer:buffer];</code></p>