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


This class provides the ability to add and remove tracks, and you can add, remove, and scale time ranges. You can make an immutable snapshot of a mutable composition for playback or inspection as follows:

AVMutableComposition *myMutableComposition =
    <#a mutable composition you want to inspect or play in its current state#>;
AVComposition *immutableSnapshotOfMyComposition = [myMutableComposition copy];
// Create a player to inspect and play the composition.
AVPlayerItem *playerItemForSnapshottedComposition =
    [[AVPlayerItem alloc] initWithAsset:immutableSnapshotOfMyComposition];


Managing Time Ranges

func insertEmptyTimeRange(CMTimeRange)

Adds or extends an empty timeRange within all tracks of the composition.

func insertTimeRange(CMTimeRange, of: AVAsset, at: CMTime)

Inserts all the tracks within a given time range of a specified asset into the receiver.

func removeTimeRange(CMTimeRange)

Removes a specified timeRange from all tracks of the composition.

func scaleTimeRange(CMTimeRange, toDuration: CMTime)

Changes the duration of all tracks in a given time range.

Managing Tracks

var tracks: [AVMutableCompositionTrack]

An array of AVMutableCompositionTrack objects contained by the composition.

func removeTrack(AVCompositionTrack)

Removes a specified track from the receiver.

func mutableTrack(compatibleWith: AVAssetTrack)

Returns a track in the receiver into which any time range of a given asset track can be inserted.

Configuring Video Size

var naturalSize: CGSize

The encoded or authored size of the visual portion of the asset.


Inherits From

Conforms To

See Also

Media Composition

class AVComposition

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

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 AVMutableCompositionTrack

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