title: Looping AVPlayer seamlessly
body: <p>There has been <a href="https://stackoverflow.com/questions/5361145/looping-a-video-with-avfoundation-avplayer">some discussion</a> before about how to loop an <code>AVPlayer</code>'s video item, but no 'solution' is seamless enough to provide <strong><em>lag-less</em> looping of a video</strong>.</p>
  
  <p>I am developing a tvOS app that has a high-quality 10 second clip of 'scenery' in the background of one of its views, and simply restarting its AVPlayer the 'standard' way (subscribing to <code>NSNotification</code> to catch it) is too jumpy not to notice and detract from user experience.</p>
  
  <p>It seems as though the only way to achieve a truly seamless loop is to manually manage frames, at a lower-level (in OpenGL)...</p>
  
  <p>Despite best efforts to read up on this, and as a novice in manipulating video pipelines, I have not come close enough to a comprehensible solution.</p>
  
  <p>I am aware that external libraries exist to be able to perform this behaviour more easily; most notably <a href="https://github.com/BradLarson/GPUImage" rel="nofollow noreferrer">GPUImage</a>. However, the app I am developing is for tvOS and therefore has difficulty using quite a lot of the 3rd party iOS libraries in existence, GPUImage included. Another library I have come across is <a href="http://www.modejong.com/AVAnimator/" rel="nofollow noreferrer">AVAnimator</a>, which provides great functionality for light-weight animation videos, but not for dense, high-quality video clips of source footage encoded in .H264.</p>
  
  <p>The closest I have come so far is Apple's own <a href="https://developer.apple.com/library/ios/samplecode/AVCustomEdit/Introduction/Intro.html" rel="nofollow noreferrer">AVCustomEdit</a> source code, however this primarily deals with static production of a 'transition' that, while seamless, is too complex for me to be able to discern how to make it perform simple looping functionality.</p>
  
  <p>If anybody can chip in with experience of manipulating <code>AVPlayer</code> at a lower level, i.e. with image processing/buffers (or iOS development that doesn't rest on external libraries), I would be incredibly interested to know how I could make a start.</p>