iOS Developer Library

Developer

AVFoundation Framework Reference AVCompositionTrackSegment Class Reference

Options
Deployment Target:

On This Page
Language:

AVCompositionTrackSegment

Inherits From


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 4.0 and later

An AVCompositionTrackSegment object represents a segment of an AVCompositionTrack object, comprising a URL, and track identifier, and a time mapping from the source track to the composition track.

You typically use this class to save the low-level representation of a composition to storage formats of your choosing and to reconstitute them from storage.

  • Returns a composition track segment that presents an empty track segment.

    Declaration

    Objective-C

    + (AVCompositionTrackSegment *)compositionTrackSegmentWithTimeRange:(CMTimeRange)timeRange

    Parameters

    timeRange

    The time range of the empty composition track segment.

    Return Value

    An composition track segment that presents an empty track segment.

    Discussion

    This method invokes initWithURL:trackID:sourceTimeRange:targetTimeRange: with a nil URL, a trackID of kCMPersistentTrackID_Invalid, a time mapping with source.start and source.duration equal to kCMTimeInvalid, and with a target equal to timeRange.

    This is the standard low-level representation of an empty track segment.

    Import Statement

    Objective-C

    @import AVFoundation;

    Availability

    Available in iOS 4.0 and later

  • Initializes a track segment that presents an empty track segment.

    Declaration

    Swift

    init!(timeRange timeRange: CMTimeRange)

    Objective-C

    - (instancetype)initWithTimeRange:(CMTimeRange)timeRange

    Parameters

    timeRange

    The time range of the empty track segment.

    Return Value

    A track segment that presents an empty track segment.

    Discussion

    This method invokes initWithURL:trackID:sourceTimeRange:targetTimeRange: with a nil URL, a trackID of kCMPersistentTrackID_Invalid, a time mapping with source.start and source.duration equal to kCMTimeInvalid, and with a target equal to timeRange.

    This is the standard low-level representation of an empty track segment.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later

  • Returns a composition track segment that presents a portion of a file referenced by a given URL.

    Declaration

    Objective-C

    + (AVCompositionTrackSegment *)compositionTrackSegmentWithURL:(NSURL *)URL trackID:(CMPersistentTrackID)trackID sourceTimeRange:(CMTimeRange)sourceTimeRange targetTimeRange:(CMTimeRange)targetTimeRange

    Parameters

    URL

    An URL that references the container file to be presented by the track segment.

    trackID

    The track identifier that specifies the track of the container file to be presented by the track segment.

    sourceTimeRange

    The time range of the track of the container file to be presented by the track segment..

    targetTimeRange

    The time range of the composition track during which the track segment is to be presented.

    Return Value

    A track segment that presents a portion of a file referenced by URL.

    Discussion

    To specify that the segment be played at the asset’s normal rate, set source.duration == target.duration in the time mapping. Otherwise, the segment will be played at a rate equal to the ratio source.duration / target.duration.

    Import Statement

    Objective-C

    @import AVFoundation;

    Availability

    Available in iOS 4.0 and later

  • Initializes a track segment that presents a portion of a file referenced by a given URL.

    Declaration

    Swift

    init!(URL URL: NSURL!, trackID trackID: CMPersistentTrackID, sourceTimeRange sourceTimeRange: CMTimeRange, targetTimeRange targetTimeRange: CMTimeRange)

    Objective-C

    - (instancetype)initWithURL:(NSURL *)URL trackID:(CMPersistentTrackID)trackID sourceTimeRange:(CMTimeRange)sourceTimeRange targetTimeRange:(CMTimeRange)targetTimeRange

    Parameters

    URL

    An URL that references the container file to be presented by the track segment.

    trackID

    The track identifier that specifies the track of the container file to be presented by the track segment.

    sourceTimeRange

    The time range of the track of the container file to be presented by the track segment..

    targetTimeRange

    The time range of the composition track during which the track segment is to be presented.

    Return Value

    A track segment that presents a portion of a file referenced by URL.

    Discussion

    To specify that the segment be played at the asset’s normal rate, set source.duration == target.duration in the time mapping. Otherwise, the segment will be played at a rate equal to the ratio source.duration / target.duration.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later

  • sourceURL sourceURL Property

    The container file of the media presented by the track segment. (read-only)

    Declaration

    Swift

    var sourceURL: NSURL! { get }

    Objective-C

    @property(nonatomic, readonly) NSURL *sourceURL

    Discussion

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later

  • The track ID of the container file of the media presented by the track segment. (read-only)

    Declaration

    Swift

    var sourceTrackID: CMPersistentTrackID { get }

    Objective-C

    @property(nonatomic, readonly) CMPersistentTrackID sourceTrackID

    Discussion

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later

  • empty empty Property

    Indicates whether the segment is empty. (read-only)

    Declaration

    Swift

    var empty: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isEmpty) BOOL empty

    Discussion

    An empty segment has a valid target time range but sourceURL is nil and the source start time is kCMTimeInvalid; all other fields are undefined.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.1 and later