title: Using AVAssetReader to read (stream) from a remote asset
body: <p>My main goal is to stream a video from a server, and cut it frame by frame while streaming (so that it can be used by OpenGL). For that, I've used this code that I found everywhere on the Internet (as I recall it was from Apple's GLVideoFrame sample code):</p>
  
  <pre><code>NSArray * tracks = [asset tracks];
  NSLog(@"%d", tracks.count);
  
  for(AVAssetTrack* track in tracks) {
  
      NSLog(@"type: %@", [track mediaType]);
  
      initialFPS = track.nominalFrameRate;
      width = (GLuint)track.naturalSize.width;
      height = (GLuint)track.naturalSize.height;
  
  
      NSError * error = nil;
  
      // _movieReader is a member variable
      @try {
          self._movieReader = [[[AVAssetReader alloc] initWithAsset:asset error:&amp;error] autorelease];
      }
      @catch (NSException *exception) {
          NSLog(@"%@ -- %@", [exception name], [exception reason]);
          NSLog(@"skipping track");
  
          continue;
      }
  
  
      if (error)
      {
          NSLog(@"CODE:%d\nDOMAIN:%@\nDESCRIPTION:%@\nFAILURE_REASON:%@", [error code], [error domain], error.localizedDescription, [error localizedFailureReason]);                                          
          continue;
      }
  
      NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
      NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
      NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key]; 
      [_movieReader addOutput:[AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:track
                                                                         outputSettings:videoSettings]];
      [_movieReader startReading];
      [self performSelectorOnMainThread:@selector(frameStarter) withObject:nil waitUntilDone:NO];
  }
  </code></pre>
  
  <p>But I always get this exception at <code>[[AVAssetReader alloc] initWithAsset:error:]</code>.</p>
  
  <pre><code>NSInvalidArgumentException -- *** -[AVAssetReader initWithAsset:error:] Cannot initialize an instance of AVAssetReader with an asset at non-local URL 'http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8'
  </code></pre>
  
  <p>So my two questions are:</p>
  
  <ol>
  <li>Is the exception really telling me that <code>AVAssetReader</code> must have a local URL? Can it be used for streaming (just like the rest of the <code>AVFoundation</code> classes)?</li>
  <li>If the <code>AVFoundation</code> approach won't work, what are other suggestions to stream the video and split its frames at the same time?</li>
  </ol>
  
  <p>Thanks a lot for your help.</p>