AVAssetTrack Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 4.0 and later.
Companion guide
Declared in
AVAssetTrack.h
Related sample code

Overview

An AVAssetTrack object provides provides the track-level inspection interface for all assets.

AVAssetTrack adopts the AVAsynchronousKeyValueLoading protocol. You should use methods in the protocol to access a track’s properties without blocking the current thread. To cancel load requests for all keys of AVAssetTrack you must message the parent AVAsset object (for example, [track.asset cancelLoading]).

Tasks

Basic Properties

Temporal Properties

Track Language Properties

Visual Characteristics

Audible Characteristics

Frame-Based Characteristics

Track Segments

Managing Metadata

Associated Tracks

Properties

asset

The asset of which the track is a part. (read-only)

@property(nonatomic, readonly) AVAsset *asset
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

availableMetadataFormats

An array containing the metadata formats available for the track. (read-only)

@property(nonatomic, readonly) NSArray *availableMetadataFormats
Discussion

The array contains NSString objects, one for each metadata format that’s available for the track (such as QuickTime user data). For possible values, see AVMetadataItem.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

availableTrackAssociationTypes

An array of association types used to associate other tracks with the track. (read-only)

@property(nonatomic, readonly) NSArray *availableTrackAssociationTypes
Discussion

The array contains NSString objects, one for each type of association for which the track has associated tracks. For possible values, see “Track Association Types”.

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

commonMetadata

An array of AVMetadataItem objects for each common metadata key for which a value is available. (read-only)

@property(nonatomic, readonly) NSArray *commonMetadata
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

enabled

Indicates whether the track is enabled according to state stored in its container or construct. (read-only)

@property(nonatomic, readonly, getter=isEnabled) BOOL enabled
Discussion

You can change the presentation state using AVPlayerItemTrack.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

estimatedDataRate

The estimated data rate of the media data referenced by the track, in bits per second. (read-only)

@property(nonatomic, readonly) float estimatedDataRate
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

extendedLanguageTag

The language tag associated with the track, as a BCP-47 language tag. (read-only)

@property(nonatomic, readonly) NSString *extendedLanguageTag
Discussion

The value may be nil if no language tag is indicated.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

formatDescriptions

The formats of media samples referenced by the track. (read-only)

@property(nonatomic, readonly) NSArray *formatDescriptions
Discussion

The array contains CMFormatDescriptions (see CMFormatDescriptionRef), each of which indicates the format of media samples referenced by the track. A track that presents uniform media (for example, encoded according to the same encoding settings) will provide an array with a count of 1.

Availability
  • Available in iOS 4.0 and later.
Related Sample Code
Declared In
AVAssetTrack.h

languageCode

The language associated with the track, as an ISO 639-2/T language code. (read-only)

@property(nonatomic, readonly) NSString *languageCode
Discussion

The value may be nil if no language is indicated.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

mediaType

The media type for the track. (read-only)

@property(nonatomic, readonly) NSString *mediaType
Discussion

For possible values, see “Media Types” in AV Foundation Constants Reference.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

minFrameDuration

The minimum duration of the track’s frames (the reciprocal of the track’s maximum frame rate). (read-only)

@property(nonatomic, readonly) CMTime minFrameDuration
Discussion

The value of this property is kCMTimeInvalid if the track’s minimum frame duration is unknown or cannot be calculated.

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

naturalSize

The natural dimensions of the media data referenced by the track. (read-only)

@property(nonatomic, readonly) CGSize naturalSize
Availability
  • Available in iOS 4.0 and later.
Related Sample Code
Declared In
AVAssetTrack.h

naturalTimeScale

A timescale in which time values for the track can be operated upon without extraneous numerical conversion. (read-only)

@property(nonatomic, readonly) CMTimeScale naturalTimeScale
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

nominalFrameRate

The frame rate of the track, in frames per second. (read-only)

@property(nonatomic, readonly) float nominalFrameRate
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

playable

Indicates whether the track is playable in the current environment. (read-only)

@property(nonatomic, readonly, getter=isPlayable) BOOL playable
Discussion

If the value of this property is YES, an AVPlayerItemTrack of an AVPlayerItem initialized with the the track’s asset can be enabled for playback.

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

preferredTransform

The transform specified in the track’s storage container as the preferred transformation of the visual media data for display purposes. (read-only)

@property(nonatomic, readonly) CGAffineTransform preferredTransform
Discussion

The value of this property is often, but not always, CGAffineTransformIdentity.

Availability
  • Available in iOS 4.0 and later.
Related Sample Code
Declared In
AVAssetTrack.h

preferredVolume

The volume specified in the track’s storage container as the preferred volume of the audible media data. (read-only)

@property(nonatomic, readonly) float preferredVolume
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

segments

The time mappings from the track’s media samples to the timeline of the track. (read-only)

@property(nonatomic, copy, readonly) NSArray *segments
Discussion

The array contains instances of AVAssetTrackSegment.

Empty edits (that is, time ranges for which no media data is available to be presented) have source.start and source.duration equal to kCMTimeInvalid.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

selfContained

Indicates whether the track references sample data only within its storage container. (read-only)

@property(nonatomic, readonly, getter=isSelfContained) BOOL selfContained
Discussion

The value is YES if the track references sample data only within its storage container, otherwise it is NO.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

timeRange

The time range of the track within the overall timeline of the asset. (read-only)

@property(nonatomic, readonly) CMTimeRange timeRange
Discussion

If the time range’s start is greater than kCMTimeZero (you can check for this value using the CMTIME_COMPARE_INLINE macro), the track does not initially have media data to present when its asset is presented. (For example, this situation can occur when an audio track is delayed in order to align the start of audio with a specific video frame.)

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

totalSampleDataLength

The total number of bytes of sample data required by the track. (read-only)

@property(nonatomic, readonly) long long totalSampleDataLength
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

trackID

The persistent unique identifier for this track of the asset. (read-only)

@property(nonatomic, readonly) CMPersistentTrackID trackID
Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

Instance Methods

associatedTracksOfType:

An array containing other tracks associated with the track using the specified association type.

- (NSArray *)associatedTracksOfType:(NSString *)trackAssociationType
Parameters
trackAssociationType

The association type for which associated tracks are requested.

Return Value

An array of AVAssetTrack objects associated with the track by trackAssociationType. May be empty if no tracks are associated through the specified association type.

Discussion

You can call this method without blocking after availableTrackAssociationTypes has been loaded.

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

hasMediaCharacteristic:

Returns a Boolean value that indicates whether the track references media with the specified media characteristic.

- (BOOL)hasMediaCharacteristic:(NSString *)mediaCharacteristic
Parameters
mediaCharacteristic

The media characteristic of interest.

For possible values, see “Media Characteristics” in AV Foundation Constants Reference, for example AVMediaCharacteristicVisual, AVMediaCharacteristicAudible, or AVMediaCharacteristicLegible.

Return Value

YES if the track references media with the specified characteristic, otherwise NO.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

metadataForFormat:

An array of metadata items, one for each metadata item in the container of the specified format.

- (NSArray *)metadataForFormat:(NSString *)format
Parameters
format

The metadata format for which items are requested.

Return Value

An array of AVMetadataItem objects, one for each metadata item in the container of the format specified by format, or nil if there is no metadata of the specified format.

Discussion

You can call this method without blocking after availableMetadataFormats has been loaded.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

samplePresentationTimeForTrackTime:

Maps the specified track time through the appropriate time mapping and returns the resulting sample presentation time.

- (CMTime)samplePresentationTimeForTrackTime:(CMTime)trackTime
Parameters
trackTime

The track time for which a sample presentation time is requested.

Return Value

The sample presentation time corresponding to trackTime; the value will be invalid if trackTime is out of range.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAssetTrack.h

segmentForTrackTime:

The track segment that corresponds to the specified track time.

- (AVAssetTrackSegment *)segmentForTrackTime:(CMTime)trackTime
Parameters
trackTime

The track time for which you want the segment.

Return Value

The track segment from the segments array that corresponds to trackTime, or nil if trackTime is out of range.

Availability
  • Available in iOS 4.0 and later.
See Also
Declared In
AVAssetTrack.h

Constants

Track Association Types

Constants for identifying how other tracks are associated with a track.

NSString *const AVTrackAssociationTypeAudioFallback;
NSString *const AVTrackAssociationTypeChapterList;
NSString *const AVTrackAssociationTypeForcedSubtitlesOnly;
NSString *const AVTrackAssociationTypeSelectionFollower;
NSString *const AVTrackAssociationTypeTimecode;
Constants
AVTrackAssociationTypeAudioFallback

An association from one audio track to another audio track. This constant indicates when one track contains the same content as another but in a more widely supported format. A player that does not support the format of the original track can use the “fallback” track instead.

For example, an asset may contain both stereo and a 5.1-channel audio tracks. In this case, marking the stereo track as the fallback for the 5.1-channel track would ensure that devices not capable of playing 5.1-channel audio can still play an equivalent track.

Available in iOS 7.0 and later.

Declared in AVAssetTrack.h.

AVTrackAssociationTypeChapterList

An association from a track to another track containing chapter information, which may be a text track, a video track, or a timed metadata track.

Available in iOS 7.0 and later.

Declared in AVAssetTrack.h.

AVTrackAssociationTypeForcedSubtitlesOnly

An association from one subtitle track, containing both forced and nonforced subtitles, to another subtitle track containing only forced subtitles for the same content.

Nonforced subtitles usually transcribe all “normal” dialogue in a media asset and are typically not presented by default. Forced subtitles are those that are essential for presentation even when normal subtitles are disabled (for example, when a character speaks in a language foreign to that of the audio track).

Available in iOS 7.0 and later.

Declared in AVAssetTrack.h.

AVTrackAssociationTypeSelectionFollower

An association from one track to another specifying that when the user selects the first track, the second should be considered an appropriate default selection.

For example, a follower for an audio track could be a subtitle track in the same language. When the user chooses a language for audio, the subtitle language “follows” the audio language selection.

Available in iOS 7.0 and later.

Declared in AVAssetTrack.h.

AVTrackAssociationTypeTimecode

An association from one track (of any type) to a timecode track containing timing information for the original track.

Available in iOS 7.0 and later.

Declared in AVAssetTrack.h.