title: iOS: AVPlayer - getting a snapshot of the current frame of a video
body: <p>I have spent the whole day and went through a lot of SO answers, Apple references, documentations, etc, but no success.</p>
  
  <p>I want a simple thing: <strong>I am playing a video using AVPlayer and I want to pause it and get the current frame as <code>UIImage</code></strong>. That's it.</p>
  
  <p>My video is a m3u8 file located on the internet, it is played normally in the <code>AVPlayerLayer</code> without any problems.</p>
  
  <p>What have I tried:</p>
  
  <ol>
  <li><strong><code>AVAssetImageGenerator</code>.</strong> It is not working, the method <code>copyCGImageAtTime:actualTime: error:</code> returns null image ref. According to the answer <a href="https://stackoverflow.com/a/33074746">here</a> <code>AVAssetImageGenerator</code> doesn't work for streaming videos.</li>
  <li><strong>Taking snapshot of the player view.</strong> I tried first <code>renderInContext:</code> on <code>AVPlayerLayer</code>, but then I realized that it is not rendering this kind of "special" layers. Then I found a new method introduced in iOS 7 - <code>drawViewHierarchyInRect:afterScreenUpdates:</code> which should be able to render also the special layers, but no luck, still got the UI snapshot with blank black area where the video is shown.</li>
  <li><strong><code>AVPlayerItemVideoOutput</code>.</strong> I have added a video output for my <code>AVPlayerItem</code>, however whenever I call <code>hasNewPixelBufferForItemTime:</code> it returns <code>NO</code>. I guess the problem is again streaming video and <a href="https://stackoverflow.com/q/24800742">I am not alone</a> with this problem.</li>
  <li><strong><code>AVAssetReader</code>.</strong> I was thinking to try it but decided not to lose time after finding a related question <a href="https://stackoverflow.com/q/6242131">here</a>.</li>
  </ol>
  
  <p>So isn't there any way to get a snapshot of something that I am anyway seeing right now on the screen? I can't believe this.</p>