AVCompositionTrackSegment Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 4.0 and later.
Declared in
AVCompositionTrackSegment.h

Overview

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.

Tasks

Creating a Segment

Segment Properties

Properties

empty

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

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

Availability
  • Available in iOS 4.1 and later.
Declared In
AVCompositionTrackSegment.h

sourceTrackID

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

@property(nonatomic, readonly) CMPersistentTrackID sourceTrackID
Discussion

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

sourceURL

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

@property(nonatomic, readonly) NSURL *sourceURL
Discussion

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

Class Methods

compositionTrackSegmentWithTimeRange:

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

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

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

compositionTrackSegmentWithURL:trackID:sourceTimeRange:targetTimeRange:

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

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

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

Instance Methods

initWithTimeRange:

Initializes a track segment that presents an empty track segment.

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

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

initWithURL:trackID:sourceTimeRange:targetTimeRange:

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

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

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