AVMutableCompositionTrack Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AVFoundation.framework |
| Availability | Available in iOS 4.0 and later. |
| Companion guide | |
| Declared in | AVCompositionTrack.h |
Overview
AVMutableCompositionTrack is a mutable subclass of AVCompositionTrack that lets you for insert, remove, and scale track segments without affecting their low-level representation (that is, the operations you perform are non-destructive on the original).
AVCompositionTrack defines constraints for the temporal alignment of the track segments. If you set the array of track segments in a mutable composition (see trackSegments), you can test whether the segments meet the constraints using validateTrackSegments:error:.
Tasks
Managing Time Ranges
-
– insertEmptyTimeRange: -
– insertTimeRange:ofTrack:atTime:error: -
– insertTimeRanges:ofTracks:atTime:error: -
– removeTimeRange: -
– scaleTimeRange:toDuration: -
segmentsproperty
Validating Segments
Track Properties
-
languageCodeproperty -
extendedLanguageTagproperty -
naturalTimeScaleproperty -
preferredTransformproperty -
preferredVolumeproperty
Properties
extendedLanguageTag
The language tag associated with the track, as an RFC 4646 language tag.
Discussion
If not set, the value is nil.
Availability
- Available in iOS 4.0 and later.
See Also
Declared In
AVCompositionTrack.hlanguageCode
The language associated with the track, as an ISO 639-2/T language code.
Discussion
If not set, the value is nil.
Availability
- Available in iOS 4.0 and later.
See Also
Declared In
AVCompositionTrack.hnaturalTimeScale
The timescale in which time values for the track can be operated upon without extraneous numerical conversion.
Discussion
If not set, the value is the natural time scale of the first non-empty edit, or 600 if there are no non-empty edits.
Set the value to 0 to revert to the default behavior.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hpreferredTransform
The preferred transformation of the visual media data for display purposes.
Discussion
If not set, the value is CGAffineTransformIdentity.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hpreferredVolume
The preferred volume of the audible media data.
Discussion
If not set, the value is 1.0.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hsegments
The composition track’s array of track segments.
Special Considerations
The timeMapping.target.start of the first track segment must be kCMTimeZero, and the timeMapping.target.start of each subsequent track segment must equal CMTimeRangeGetEnd(<#previousTrackSegment#>.timeMapping.target). You can use validateTrackSegments:error: to ensure that an array of track segments conforms to this rule.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hInstance Methods
insertEmptyTimeRange:
Adds or extends an empty time range within the receiver.
Parameters
- timeRange
The empty time range to be inserted.
Discussion
If you insert an empty time range into the track, any media that was presented during that interval prior to the insertion will be presented instead immediately afterward.
The nature of the data inserted depends upon the media type of the track. For example, an empty time range in a sound track presents silence.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hinsertTimeRange:ofTrack:atTime:error:
Inserts a time range of a source track.
Parameters
- timeRange
The time range of the track to be inserted.
- track
The source track to be inserted.
- startTime
The time at which track is to be presented by the composition track.
- error
If track is not inserted successfully, contains an
NSErrorobject that describes the problem.
Return Value
YES if track was inserted successfully, otherwise NO.
Discussion
By default, the inserted track’s time range is presented at its natural duration and rate. You can scale it to a different duration (so that it is presented at a different rate) using scaleTimeRange:toDuration:.
Insertion might fail if, for example, the asset that you try to insert is restricted by copy-protection.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hinsertTimeRanges:ofTracks:atTime:error:
Inserts the timeRanges of multiple source tracks into a track of a composition.
Parameters
- timeRanges
An array of
NSValueobjects containingCMTimeRangestructures indicating the time ranges to be inserted.- tracks
The source tracks to be inserted.
Only instances of
AVURLAssetare supported.- startTime
The time at which the inserted tracks are to be presented by the composition track.
- error
In an error occurs, upon return contains an
NSErrorobject that describes the problem.(For example, the asset that was selected for insertion in the composition is restricted by copy-protection.)
Return Value
YES if the insertions were successful, otherwise NO.
Discussion
This method is equivalent to (but more efficient than) calling -insertTimeRange:ofTrack:atTime:error:: for each timeRange/track pair.
If this method returns an error, none of the time ranges will be inserted into the composition track.
To specify an empty time range, pass an NSNull object for the track and a time range of starting at kCMTimeInvalid with a duration of the desired empty edit.
Availability
- Available in iOS 5.0 and later.
Declared In
AVCompositionTrack.hremoveTimeRange:
Removes a specified time range from the receiver.
Parameters
- timeRange
The time range to be removed.
Discussion
Removing a time range does not cause the track to be removed from the composition. Instead it removes or truncates track segments that intersect with the time range.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hscaleTimeRange:toDuration:
Changes the duration of a time range in the receiver.
Parameters
- timeRange
The time range of the track to be scaled.
- duration
The new duration of timeRange.
Discussion
Each track segment affected by the scaling operation will be presented at a rate equal to source.duration / target.duration of its resulting timeMapping.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.hvalidateTrackSegments:error:
Returns a Boolean value that indicates whether a given array of track segments conform to the timing rules for a composition track.
Parameters
- trackSegments
An array of
AVCompositionTrackSegmentobjects.- error
If validation fails, on return contains an
NSErrorobject that describes the problem.
Return Value
YES if the track segments in trackSegments conform to the timing rules for a composition track, otherwise NO.
Discussion
You can use this method to ensure that an array of track segments is suitable for setting as the value of the trackSegments property. The timeMapping.target.start of the first track segment must be kCMTimeZero, and the timeMapping.target.start of each subsequent track segment must equal CMTimeRangeGetEnd(<#previousTrackSegment#>.timeMapping.target).
If you want to modify the existing trackSegments array, you can create a mutable copy of it, modify the mutable array, and then validate the mutable array using this method.
Availability
- Available in iOS 4.0 and later.
Declared In
AVCompositionTrack.h© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-10-12)