Class

AVComposition

An object that combines media data from multiple file-based sources to present or process media data from multiple sources together.

Overview

At its top-level, AVComposition is a collection of tracks, each presenting media of a specific media type, e.g. audio or video, according to a timeline. Each track is represented by an instance of AVCompositionTrack. Each track is comprised of an array of track segments, represented by instances of AVCompositionTrackSegment. Each segment presents a portion of the media data stored in a source container, specified by URL, a track identifier, and a time mapping. The URL specifies the source container, and the track identifier indicates the track of the source container to be presented. All file-based audiovisual assets are eligible to be combined, regardless of container type.

The time mapping specifies the temporal range of the source track that's to be presented and also specifies the temporal range of its presentation in the composition track. If the durations of the source and destination ranges of the time mapping are the same, the media data for the segment will be presented at its natural rate. Otherwise, the segment will be presented at a rate equal to the ratio source.duration / target.duration.

You can access the track segments of a track using the segments property (an array of AVCompositionTrackSegment objects) of AVCompositionTrack. The collection of tracks with media type information for each, and each with its array of track segments (URL, track identifier, and time mapping), form a complete low-level representation of a composition. This representation can be written out by clients in any convenient form, and subsequently the composition can be reconstituted by instantiating a new AVMutableComposition with AVMutableCompositionTrack objects of the appropriate media type, each with its segments property set according to the stored array of URL, track identifier, and time mapping.

A higher-level interface for constructing compositions is also presented by AVMutableComposition and AVMutableCompositionTrack, offering insertion, removal, and scaling operations without direct manipulation of the trackSegment arrays of composition tracks. This interface makes use of higher-level constructs such as AVAsset and AVAssetTrack, allowing the client to make use of the same references to candidate sources that it would have created in order to inspect or preview them prior to inclusion in a composition.

Relationships

Inherits From

See Also

Media Composition

class AVCompositionTrack

A track in a composition object, consisting of a media type, a track identifier, and track segments.

class AVCompositionTrackSegment

A segment of a track, consisting of a URL, a track identifier, and a time mapping from the source track to the composition track.

class AVMutableComposition

A mutable object used to create a new composition from existing assets.

class AVMutableCompositionTrack

A mutable track in a composition object that you use to insert, remove, and scale track segments without affecting their low-level representation.