Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's unclear from your question whether you are talking about video samples or audio samples. To read video samples, you need to do the following:</p> <ol> <li><p>Construct an AVAssetReader:</p> <p><code>asset_reader = [[AVAssetReader alloc] initWithAsset:asset error:&amp;error]; (error checking goes here)</code></p></li> <li><p>Get the video track(s) from your asset:</p> <p><code>NSArray* video_tracks = [asset tracksWithMediaType:AVMediaTypeVideo]; AVAssetTrack* video_track = [video_tracks objectAtIndex:0];</code></p></li> <li><p>Set the desired video frame format:</p> <pre>NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; [dictionary setObject:[NSNumber numberWithInt:&lt;format code from CVPixelBuffer.h&gt;] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey];</pre> <p>Note that certain video formats just will not work, and if you're doing something real-time, certain video formats perform better than others (BGRA is faster than ARGB, for instance).</p></li> <li><p>Construct the actual track output and add it to the asset reader:</p> <pre>AVAssetReaderTrackOutput* asset_reader_output = [[AVAssetReaderTrackOutput alloc] initWithTrack:video_track outputSettings:dictionary]; [asset_reader addOutput:asset_reader_output];</pre></li> <li><p>Kick off the asset reader:</p> <p><code>[asset_reader startReading];</code></p></li> <li><p>Read off the samples:</p> <pre> CMSampleBufferRef buffer; while ( [asset_reader status]==AVAssetReaderStatusReading ) buffer = [asset_reader_output copyNextSampleBuffer]; </pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload