Mac Developer Library

Developer

AVFoundation Framework Reference AVAssetTrack Class Reference

Options
Deployment Target:

On This Page
Language:

AVAssetTrack

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

Inheritance


Import Statement


import AVFoundation @import AVFoundation;

Availability


Available in OS X v10.7 and later.
  • asset asset Property

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

    Declaration

    Swift

    var asset: AVAsset! { get }

    Objective-C

    @property(nonatomic, readonly) AVAsset *asset

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • trackID trackID Property

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

    Declaration

    Swift

    var trackID: CMPersistentTrackID { get }

    Objective-C

    @property(nonatomic, readonly) CMPersistentTrackID trackID

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • mediaType mediaType Property

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

    Declaration

    Swift

    var mediaType: String! { get }

    Objective-C

    @property(nonatomic, readonly) NSString *mediaType

    Discussion

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    func hasMediaCharacteristic(_ mediaCharacteristic: String!) -> Bool

    Objective-C

    - (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

    YEStrue if the track references media with the specified characteristic, otherwise NOfalse.

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var formatDescriptions: [AnyObject]! { get }

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • enabled enabled Property

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

    Declaration

    Swift

    var enabled: Bool { get }

    Objective-C

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

    Discussion

    You can change the presentation state using AVPlayerItemTrack.

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • playable playable Property

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

    Declaration

    Swift

    var playable: Bool { get }

    Objective-C

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

    Discussion

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.8 and later.

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

    Declaration

    Swift

    var selfContained: Bool { get }

    Objective-C

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

    Discussion

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var totalSampleDataLength: Int64 { get }

    Objective-C

    @property(nonatomic, readonly) long long totalSampleDataLength

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • timeRange timeRange Property

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

    Declaration

    Swift

    var timeRange: CMTimeRange { get }

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var naturalTimeScale: CMTimeScale { get }

    Objective-C

    @property(nonatomic, readonly) CMTimeScale naturalTimeScale

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var estimatedDataRate: Float { get }

    Objective-C

    @property(nonatomic, readonly) float estimatedDataRate

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var languageCode: String! { get }

    Objective-C

    @property(nonatomic, readonly) NSString *languageCode

    Discussion

    The value may be nil if no language is indicated.

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var extendedLanguageTag: String! { get }

    Objective-C

    @property(nonatomic, readonly) NSString *extendedLanguageTag

    Discussion

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

    See Also

    languageCode

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

    Declaration

    Swift

    var naturalSize: CGSize { get }

    Objective-C

    @property(nonatomic, readonly) CGSize naturalSize

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var preferredTransform: CGAffineTransform { get }

    Objective-C

    @property(nonatomic, readonly) CGAffineTransform preferredTransform

    Discussion

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var preferredVolume: Float { get }

    Objective-C

    @property(nonatomic, readonly) float preferredVolume

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var nominalFrameRate: Float { get }

    Objective-C

    @property(nonatomic, readonly) float nominalFrameRate

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var minFrameDuration: CMTime { get }

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.10 and later.

  • A Boolean value that indicates whether samples in the track may have different values for their presentation and decode timestamps. (read-only)

    Declaration

    Swift

    var requiresFrameReordering: Bool { get }

    Objective-C

    @property(nonatomic, readonly) BOOL requiresFrameReordering

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.10 and later.

  • segments segments Property

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

    Declaration

    Swift

    var segments: [AnyObject]! { get }

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • The track segment that corresponds to the specified track time.

    Declaration

    Swift

    func segmentForTrackTime(_ trackTime: CMTime) -> AVAssetTrackSegment!

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

    See Also

    segments

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

    Declaration

    Swift

    func samplePresentationTimeForTrackTime(_ trackTime: CMTime) -> CMTime

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var commonMetadata: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *commonMetadata

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    func metadataForFormat(_ format: String!) -> [AnyObject]!

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var availableMetadataFormats: [AnyObject]! { get }

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.7 and later.

  • metadata metadata Property

    An array of metadata items for all metadata identifiers for which a value is available. (read-only)

    Declaration

    Swift

    var metadata: [AnyObject]! { get }

    Objective-C

    @property(nonatomic, readonly) NSArray *metadata

    Discussion

    The array of AVMetadataItem instances can be filtered according to language using the metadataItemsFromArray:filteredAndSortedAccordingToPreferredLanguages: method. They can be filtered by identifier using the metadataItemsFromArray:filteredByIdentifier:method.

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.10 and later.

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

    Declaration

    Swift

    func associatedTracksOfType(_ trackAssociationType: String!) -> [AnyObject]!

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.9 and later.

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

    Declaration

    Swift

    var availableTrackAssociationTypes: [AnyObject]! { get }

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in OS X v10.9 and later.

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

    Declaration

    Swift

    let AVTrackAssociationTypeAudioFallback: NSString! let AVTrackAssociationTypeChapterList: NSString! let AVTrackAssociationTypeForcedSubtitlesOnly: NSString! let AVTrackAssociationTypeSelectionFollower: NSString! let AVTrackAssociationTypeTimecode: NSString! let AVTrackAssociationTypeMetadataReferent: NSString!

    Objective-C

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

    Constants

    • AVTrackAssociationTypeAudioFallback

      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 OS X v10.9 and later.

    • AVTrackAssociationTypeChapterList

      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 OS X v10.9 and later.

    • AVTrackAssociationTypeForcedSubtitlesOnly

      AVTrackAssociationTypeForcedSubtitlesOnly

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

      Non-forced 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 OS X v10.9 and later.

    • AVTrackAssociationTypeSelectionFollower

      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 OS X v10.9 and later.

    • AVTrackAssociationTypeTimecode

      AVTrackAssociationTypeTimecode

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

      Available in OS X v10.9 and later.

    • AVTrackAssociationTypeMetadataReferent

      AVTrackAssociationTypeMetadataReferent

      An optional association for AVAssetTracks with the mediaType AVMediaTypeMetadata. When a metadata track lacks this track association, its contents are assumed to describe or annotate the asset as a whole.

      Available in OS X v10.10 and later.

    Import Statement