title: - copyPixelBufferForItemTime:itemTimeForDisplay: null value
body: <p>The issue I have is when I compile my app with iOS9 sdk when my app try to get a <code>CVPixelBufferRef</code> from an <code>AVPlayerItemVideoOutput</code> with the <code>- copyPixelBufferForItemTime:itemTimeForDisplay:</code> function I get a null value from time to time when the video is loaded and all the instances are created.</p>
  
  <p>with iOS 8 my app was working fine, but with iOS9 is giving me the issue, even the version of my app that is in the app store available for download that was compiled with iOS 8 SDK is giving me the same problem when is installed in IOS9.</p>
  
  <p>When the  problem happens and I get a null <code>getCVPixelBufferRef</code>, if I press the home button and the app goes to background when I open the app again and becomes active the <code>AVPlayerItemVideoOutput</code> instance that was giving me the null <code>CVPixelBufferRef</code> starts to work fine and the issue is solved.</p>
  
  <p>Here is a youtube video where I replicate the issue:</p>
  
  <p><a href="https://www.youtube.com/watch?v=997zG08_DMM&amp;feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=997zG08_DMM&amp;feature=youtu.be</a></p>
  
  <p>Here is the sample code in order to create the instances of all the items:</p>
  
  <pre><code>NSURL *url ;
  url = [[NSURL alloc] initFileURLWithPath:[_mainVideo objectForKey:@"file"]];
  
  NSDictionary *pixBuffAttributes = @{(id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange)};
  _videoOutput = [[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:pixBuffAttributes];
  _myVideoOutputQueue = dispatch_queue_create("myVideoOutputQueue", DISPATCH_QUEUE_SERIAL);
  [_videoOutput setDelegate:self queue:_myVideoOutputQueue];
  
  _player = [[AVPlayer alloc] init];
  
  
  // Do not take mute button into account
  NSError *error = nil;
  BOOL success = [[AVAudioSession sharedInstance]
                  setCategory:AVAudioSessionCategoryPlayback
                  error:&amp;error];
  if (!success) {
     // NSLog(@"Could not use AVAudioSessionCategoryPlayback", nil);
  }
  
  asset = [AVURLAsset URLAssetWithURL:url options:nil];
  
  
  if(![[NSFileManager defaultManager] fileExistsAtPath:[[asset URL] path]]) {
     // NSLog(@"file does not exist");
  }
  
  NSArray *requestedKeys = [NSArray arrayWithObjects:kTracksKey, kPlayableKey, nil];
  
  [asset loadValuesAsynchronouslyForKeys:requestedKeys completionHandler:^{
  
      dispatch_async( dispatch_get_main_queue(),
                     ^{
                         /* Make sure that the value of each key has loaded successfully. */
                         for (NSString *thisKey in requestedKeys)
                         {
                             NSError *error = nil;
                             AVKeyValueStatus keyStatus = [asset statusOfValueForKey:thisKey error:&amp;error];
                             if (keyStatus == AVKeyValueStatusFailed)
                             {
                                 [self assetFailedToPrepareForPlayback:error];
                                 return;
                             }
                         }
  
                         NSError* error = nil;
                         AVKeyValueStatus status = [asset statusOfValueForKey:kTracksKey error:&amp;error];
                         if (status == AVKeyValueStatusLoaded)
                         {
                             //_playerItem = [AVPlayerItem playerItemWithAsset:asset];
  
  
                             [_playerItem addOutput:_videoOutput];
                             [_player replaceCurrentItemWithPlayerItem:_playerItem];
                             [_videoOutput requestNotificationOfMediaDataChangeWithAdvanceInterval:ONE_FRAME_DURATION];
  
                             /* When the player item has played to its end time we'll toggle
                              the movie controller Pause button to be the Play button */
                             [[NSNotificationCenter defaultCenter] addObserver:self
                                                                      selector:@selector(playerItemDidReachEnd:)
                                                                          name:AVPlayerItemDidPlayToEndTimeNotification
                                                                        object:_playerItem];
  
                             seekToZeroBeforePlay = NO;
  
                             [_playerItem addObserver:self
                                           forKeyPath:kStatusKey
                                              options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
                                              context:AVPlayerDemoPlaybackViewControllerStatusObservationContext];
  
                             [_player addObserver:self
                                       forKeyPath:kCurrentItemKey
                                          options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
                                          context:AVPlayerDemoPlaybackViewControllerCurrentItemObservationContext];
  
                             [_player addObserver:self
                                       forKeyPath:kRateKey
                                          options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
                                          context:AVPlayerDemoPlaybackViewControllerRateObservationContext];
  
  
                             [self initScrubberTimer];
  
                             [self syncScrubber];
  
  
                         }
                         else
                         {
                           //  NSLog(@"%@ Failed to load the tracks.", self);
                         }
                     });
  }];
  </code></pre>
  
  <p>Heres the sample code giving me the null pixel buffer</p>
  
  <pre><code>CVPixelBufferRef pixelBuffer =
  [_videoOutput
   copyPixelBufferForItemTime:[_playerItem currentTime]
  itemTimeForDisplay:nil];
  
  NSLog(@"the pixel buffer is %@", pixelBuffer);
  NSLog (@"the _videoOutput is %@", _videoOutput.description);
  CMTime dataTime = [_playerItem currentTime];
  //NSLog(@"the current time is %f", dataTime);
  return pixelBuffer;
  </code></pre>