title: iOS: How to make a movie with a series of images using AVAssetWriter
body: <p>I have seen this question asked many times in different forms both here and in other forums.  Some of the questions get answered, some do not.  There are a few where the answerer or author claims to have had success.  I have implemented the examples from those that claim success, but have yet to see the same results.  </p>
  
  <p>I am able to successfully use AVAssetWriter (and AVAssetWriterInputPixelBufferAdaptor) to write image data and audio data simultaneously when the sample buffers are obtained from an AVCaptureSession.  However, if I have CGImageRef's that were generated in some other way, and build a CVPixelBufferRef "from scratch", the appendPixelBuffer:withPresentationTime method of AVAssetWriterInputPixelBufferAdaptor succeeds for a few frames and then fails for all subsequent frames.  The resulting movie file is of course not valid.  </p>
  
  <p>You can see my example code at: <a href="http://pastebin.com/FCJZJmMi" rel="nofollow">http://pastebin.com/FCJZJmMi</a></p>
  
  <p>The images are valid, and are verified by displaying them in a debug window (see lines 50-53).  The app has been tested with Instruments, and memory utilization is low throughout the running of the app.  It does not get any memory warnings. </p>
  
  <p>As far as I can tell I have followed the documentation that is available. Why does the example code fail?  What needs to be done to fix it? </p>
  
  <p>If anybody has successfully gotten AVAssetWriterInputPixelBufferAdaptor to work with their own images, please chime in. </p>