iOS Developer Library

Developer

AVFoundation Framework Reference AVAssetReaderTrackOutput Class Reference

Options
Deployment Target:

On This Page
Language:

AVAssetReaderTrackOutput

Inherits From


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 4.1 and later

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:

 

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

    Declaration

    Objective-C

    + (instancetype)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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Availability

    Available in iOS 4.1 and later

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

    Declaration

    Swift

    init!(track track: AVAssetTrack!, outputSettings outputSettings: [NSObject : AnyObject]!)

    Objective-C

    - (instancetype)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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

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

    Declaration

    Swift

    var outputSettings: [NSObject : AnyObject]! { get }

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

  • track track Property

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

    Declaration

    Swift

    var track: AVAssetTrack! { get }

    Objective-C

    @property(nonatomic, readonly) AVAssetTrack *track

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later

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

    Declaration

    Swift

    var audioTimePitchAlgorithm: String!

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later