AVAssetReaderOutput Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 4.1 and later.
Companion guide
Declared in
AVAssetReaderOutput.h

Overview

AVAssetReaderOutput is an abstract class that defines an interface for reading a single collection of samples of a common media type from an AVAssetReader object.

There are several subclasses of AVAssetReaderOutput for specific tasks, such as AVAssetReaderTrackOutput or AVAssetReaderVideoCompositionOutput.

You can read the media data of an asset by adding one or more concrete instances of AVAssetReaderOutput to an AVAssetReader object using addOutput:.

Tasks

Copying a Buffer

Inspecting the Media Type

Properties

alwaysCopiesSampleData

Indicates whether the data in buffers gets copied before being vended.

@property(nonatomic) BOOL alwaysCopiesSampleData
Discussion

When the value of this property is YES, the output always vends a buffer with copied data—you can freely modify data in such buffers.

When the value of this property is NO, the buffers vended may not be copied—such buffers may still be referenced by other entities. The result of modifying a buffer whose data hasn't been copied is undefined.

Requesting buffers whose data hasn’t been copied when possible can lead to performance improvements.

The default value of this property is YES

Availability
  • Available in iOS 5.0 and later.
Declared In
AVAssetReaderOutput.h

mediaType

A string representing the media type of the track (or tracks) represented by the output. (read-only)

@property(nonatomic, readonly) NSString *mediaType
Discussion

The value of this property is one of the media type strings defined in AVMediaFormat.h.

Availability
  • Available in iOS 4.1 and later.
Declared In
AVAssetReaderOutput.h

Instance Methods

copyNextSampleBuffer

Synchronously copies the next sample buffer for the output.

- (CMSampleBufferRef)copyNextSampleBuffer
Return Value

The output sample buffer, or NULL if there are no more sample buffers available for the output within the time range specified by the asset reader’s timeRange property. Ownership follows the “The Create Rule” in Memory Management Programming Guide for Core Foundation.

Discussion

If this method returns NULL, you should check the value of the associated AVAssetReader object’s status property to determine why no more samples could be read.

Availability
  • Available in iOS 4.1 and later.
Declared In
AVAssetReaderOutput.h