AVAssetReaderTrackOutput Class Reference

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

Overview

AVAssetReaderTrackOutput defines an interface for reading media data from a single AVAssetTrack object of an asset reader's asset.

You can read the media data of an asset track by adding an instance of AVAssetReaderTrackOutput to an asset reader using the AVAssetReader method addOutput:. The samples in the track can be read in the format in which they are stored in the asset, or can be converted to a different format.

The AVAssetReaderTrackOutput class can only produce uncompressed output.  For audio output settings, this means that AVFormatIDKey must be kAudioFormatLinearPCM.  For video output settings, this means that the dictionary must contain values for uncompressed video output, as defined in Video_Settings.  AVAssetReaderTrackOutput does not support the AVSampleRateConverterAudioQualityKey key or the following Video_Settings keys: AVVideoCleanApertureKey, AVVideoPixelAspectRatioKey, AVVideoScalingModeKey, or the AVVideoColorPropertiesKey key.

When constructing video output settings the choice of pixel format will affect the performance and quality of the decompression. For optimal performance when decompressing video the requested pixel format should be one that the decoder supports natively to avoid unnecessary conversions. Below are some recommendations:

 

Tasks

Creating a Track Output

Properties

Properties

audioTimePitchAlgorithm

The processing algorithm used to manage audio pitch for scaled audio edits.

@property(nonatomic, copy) NSString *audioTimePitchAlgorithm
Discussion

The supported constants are defined in Time Pitch Algorithm Settings.

An NSInvalidArgumentException will be raised if this property is set to a value other than the defined constants.

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

outputSettings

The output settings used by the output. (read-only)

@property(nonatomic, readonly) NSDictionary *outputSettings
Discussion

The value is a dictionary that contains values for keys from either Linear_PCM_Format_Settingsfor audio tracks or CVPixelBufferRef for video tracks. A value of nil indicates that the output will return samples in their original format as stored in the target track.

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

track

The track from which the receiver reads sample buffers. (read-only)

@property(nonatomic, readonly) AVAssetTrack *track
Availability
  • Available in iOS 4.1 and later.
Declared In
AVAssetReaderOutput.h

Class Methods

assetReaderTrackOutputWithTrack:outputSettings:

Returns an asset reader wrapping a specified track, with optional output settings.

+ (AVAssetReaderTrackOutput *)assetReaderTrackOutputWithTrack:(AVAssetTrack *)track outputSettings:(NSDictionary *)outputSettings
Parameters
track

The track from which the reader should source sample buffers.

outputSettings

A dictionary of output settings to be used for sample output.

You use keys from one of AVAudioSettings.h, Video_Settings, or CVPixelBufferRef, depending on the media type and the output format required.

A value of nil configures the output to vend samples in their original format as stored by the specified track.

Initialization fails if the output settings cannot be used with the specified track.

Return Value

An asset reader wrapping track, using the setting defined by outputSettings, nil if initialization fails.

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

Instance Methods

initWithTrack:outputSettings:

Initializes an asset reader to wrap a specified track, with optional output settings.

- (id)initWithTrack:(AVAssetTrack *)track outputSettings:(NSDictionary *)outputSettings
Parameters
track

The track from which the reader should source sample buffers.

outputSettings

A dictionary of output settings to be used for sample output. Pass nil to receive samples as stored in the track.

You use keys from one of AVAudioSettings.h, Video_Settings, or CVPixelBufferRef, depending on the media type and the output format required.

A value of nil configures the output to vend samples in their original format as stored by the specified track.

Initialization fails if the output settings cannot be used with the specified track.

Return Value

An asset reader wrapping track, using the setting defined by outputSettings, nil if initialization fails.

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