title: How to use CVPixelBufferPool in conjunction with AVAssetWriterInputPixelBufferAdaptor in iPhone?
body: <p>I have successfully created video from images using the following code</p>
  
  <pre><code>-(void)writeImageAsMovie:(NSArray *)array toPath:(NSString*)path size:(CGSize)size duration:(int)duration 
  {
      NSError *error = nil;
      AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:
                                    [NSURL fileURLWithPath:path] fileType:AVFileTypeQuickTimeMovie
                                                                error:&amp;error];
      NSParameterAssert(videoWriter);
  
      NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                     AVVideoCodecH264, AVVideoCodecKey,
                                     [NSNumber numberWithInt:size.width], AVVideoWidthKey,
                                     [NSNumber numberWithInt:size.height], AVVideoHeightKey,
                                     nil];
      AVAssetWriterInput* writerInput = [[AVAssetWriterInput
                                          assetWriterInputWithMediaType:AVMediaTypeVideo
                                          outputSettings:videoSettings] retain];
  
      AVAssetWriterInputPixelBufferAdaptor *adaptor = [AVAssetWriterInputPixelBufferAdaptor
                                                       assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput
                                                       sourcePixelBufferAttributes:nil];
      NSParameterAssert(writerInput);
      NSParameterAssert([videoWriter canAddInput:writerInput]);
      [videoWriter addInput:writerInput];
  
  
      //Start a session:
      [videoWriter startWriting];
      [videoWriter startSessionAtSourceTime:kCMTimeZero];
  
      CVPixelBufferRef buffer = NULL;
      buffer = [self pixelBufferFromCGImage:[[array objectAtIndex:0] CGImage]];
      [adaptor appendPixelBuffer:buffer withPresentationTime:kCMTimeZero];
  
      //Write samples:
      for (int i = 0;i&lt;[array count]; i++)
      {
          if([writerInput isReadyForMoreMediaData])
          {
              NSLog(@"inside for loop %d",i);
              CMTime frameTime = CMTimeMake(1, 20);
  
              CMTime lastTime=CMTimeMake(i, 20); //i is from 0 to 24 of the loop above
  
              CMTime presentTime=CMTimeAdd(lastTime, frameTime);
  
              buffer = [self pixelBufferFromCGImage:[[array objectAtIndex:i] CGImage]];
  
              [adaptor appendPixelBuffer:buffer withPresentationTime:presentTime];
  
          }
          else
          {
              NSLog(@"error");
              i--;
          }
      }
      NSLog(@"outside for loop");
  
      //Finish the session:
      [writerInput markAsFinished];
      [videoWriter finishWriting];
  }
  </code></pre>
  
  <p>Here I have used <code>CVPixelBufferRef</code>. Instead of this, I want to use the <code>CVPixelBufferPoolRef</code> in conjunction with <code>AVAssetWriterInputPixelBufferAdaptor</code>.</p>
  
  <p>Can anybody provide an example which I can debug and use?</p>