An object that defines an interface for reading media data from a single track of an asset reader's asset.


class AVAssetReaderTrackOutput : AVAssetReaderOutput


You can read the media data of an asset track by adding an instance of AVAssetReaderTrackOutput to an asset reader using the AVAssetReader method add(_:). You can read the samples in the track in their stored format, or you can convert them 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 affects 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:



Creating a Track Output

init(track: AVAssetTrack, outputSettings: [String : Any]?)

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

Video Settings Dictionaries

Define output image and video formats by using the key and value constants.

Retrieving Output Properties

var outputSettings: [String : Any]?

The settings used by the output.

var track: AVAssetTrack

The track from which the receiver reads sample buffers.

var audioTimePitchAlgorithm: AVAudioTimePitchAlgorithm

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


Inherits From

Conforms To

See Also

File Import

class AVAssetReader

A reader object used to obtain the media data of an asset, either file-based or consisting of an assemblage of media data from multiple sources.

class AVAssetReaderAudioMixOutput

An object that defines an interface for reading audio samples that result from mixing the audio from one or more tracks.

class AVAssetReaderSampleReferenceOutput

An object that defines an interface for reading sample references from a single asset track.

class AVAssetReaderVideoCompositionOutput

An object that reads video frames composited from the frames in one or more tracks of a reader's assets.

class AVAssetReaderOutput

An abstract class that defines an interface for reading a single collection of samples of a common media type from an asset reader object.

class AVAssetReaderOutputMetadataAdaptor

An object that defines an interface for reading metadata.

class AVAssetImageGenerator

An object that provides thumbnail or preview images of assets independently of playback.