title: The encoder required for this media is busy
body: <p>When attempting to concatenate multiple videos into one via the AVAssetWriter and AVAssetWriterInput approach.  After the 3rd video I receive a 'Cannot Encode' error from the AVAssetWriter.error.  </p>
  
  <p>Additionally, I am able to see via the console successful reads to the buffer, but only the very last successfully read video winds up in the concatenated mov.  Any insight into either or both issues appreciated, source and log below.  Thanks</p>
  
  <pre><code>+(void)doWriteWithVideoWriter:(AVAssetWriter *)videoWriter withIndex:(int)index withWriterInputArray:(NSMutableArray *)writersArray withInstance:(VideoCombinerManager *)theInstance{
  if ([writersArray count] &gt; 0)
  {
      int newIndex = index+1;
  
      NSError *readerError;
      NSDictionary *videoOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
  
      AVAsset *sourceAsset = [theInstance.loadedAssetsForCompilationDictionary objectForKey:[theInstance.sortedKeysArray objectAtIndex:index]];
      AVAssetTrack *videoTrack = [[sourceAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
      AVAssetReaderTrackOutput *currentReaderTrackOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:videoTrack outputSettings:videoOptions];
      AVAssetReader *currentReader = [[AVAssetReader alloc] initWithAsset:sourceAsset error:&amp;readerError];
      [currentReader addOutput:currentReaderTrackOutput];
      [currentReader startReading];
  
      AVAssetWriterInput *writerInput = [[writersArray objectAtIndex:0] retain];
  
      dispatch_queue_t _processingQueue = dispatch_queue_create("asdf", NULL);
      [writerInput requestMediaDataWhenReadyOnQueue:_processingQueue usingBlock:^{
      if ([writerInput isReadyForMoreMediaData])
      {
          CMSampleBufferRef nextSampleBuffer;
  
          if ([currentReader status] == AVAssetReaderStatusReading &amp;&amp;
          (nextSampleBuffer = [currentReaderTrackOutput copyNextSampleBuffer])) {
  
          if (nextSampleBuffer)
          {
              BOOL result = [writerInput appendSampleBuffer:nextSampleBuffer];
              if (!result)
              {
              NSLog(@"videoWriter.error.userInfo: %@", videoWriter.error.userInfo);
              }
              CFRelease(nextSampleBuffer);
          }
          }
          else
          {
          NSLog(@"writer done: %d", index);
          dispatch_release(_processingQueue);
  
          [writersArray removeObjectAtIndex:0];
  
          [writerInput markAsFinished];
          [writerInput release];
  
          [currentReader release];
          [currentReaderTrackOutput release];
  
          [VideoCombinerManager doWriteWithVideoWriter:videoWriter withIndex:newIndex withWriterInputArray:writersArray withInstance:theInstance];
          }
      }
      }];
  }
  else
      [videoWriter finishWriting];
  
  }
  </code></pre>
  
  <p>writer done: 0</p>
  
  <p>writer done: 1</p>
  
  <p>writer done: 2</p>
  
  <pre><code>videoWriter.error.userInfo: {
      NSLocalizedDescription = "Cannot Encode";
      NSLocalizedFailureReason = "The encoder required for this media is busy.";
      NSLocalizedRecoverySuggestion = "Stop any other actions that encode media and try again.";
      NSUnderlyingError = "Error Domain=NSOSStatusErrorDomain Code=-12915 \"The operation couldn\U2019t be completed. (OSStatus error -12915.)\"";
  }
  
  videoWriter.error.userInfo: {
      NSLocalizedDescription = "Cannot Encode";
      NSLocalizedFailureReason = "The encoder required for this media is busy.";
      NSLocalizedRecoverySuggestion = "Stop any other actions that encode media and try again.";
      NSUnderlyingError = "Error Domain=NSOSStatusErrorDomain Code=-12915 \"The operation couldn\U2019t be completed. (OSStatus error -12915.)\"";
  }
  </code></pre>