<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVMutableComposition",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVMutableComposition"
  },
  "title" : "AVMutableComposition"
}
-->

# AVMutableComposition

An object that you use to create a new composition from existing assets.

```
class AVMutableComposition
```

## Overview

Use this object to add and remove composition tracks, and add, remove, and scale their time ranges. You can make an immutable snapshot of a mutable composition for playback and inspection as follows:

```swift
// Use a mutable composition object you create.
let mutableComposition = AVMutableComposition()
        
guard let composition = mutableComposition.copy() as? AVComposition else { return }
        
// Create a player item to inspect and play the composition.
let playerItem = AVPlayerItem(asset: composition)
```

## Topics

### Creating a composition

[`composition`](/documentation/AVFoundation/AVMutableComposition/composition)

Returns a new mutable composition.

[`init(urlAssetInitializationOptions:)`](/documentation/AVFoundation/AVMutableComposition/init(urlAssetInitializationOptions:)-rh4y)

Creates a mutable composition that uses the specified initialization options.

### Loading tracks

[`tracks`](/documentation/AVFoundation/AVPartialAsyncProperty/tracks-92p4a)

The tracks that a composition contains.

[`loadTrack(withTrackID:completionHandler:)`](/documentation/AVFoundation/AVMutableComposition/loadTrack(withTrackID:completionHandler:))

Loads a track that contains the specified identifier.

[`loadTracks(withMediaType:completionHandler:)`](/documentation/AVFoundation/AVMutableComposition/loadTracks(withMediaType:completionHandler:))

Loads tracks that contain media of a specified type.

[`loadTracks(withMediaCharacteristic:completionHandler:)`](/documentation/AVFoundation/AVMutableComposition/loadTracks(withMediaCharacteristic:completionHandler:))

Loads tracks that contain media of a specified characteristic.

### Accessing tracks

Prefer loading tracks asynchronously using the methods in Loading Tracks.

[`tracks`](/documentation/AVFoundation/AVMutableComposition/tracks)

The tracks that a composition contains.

[`track(withTrackID:)`](/documentation/AVFoundation/AVMutableComposition/track(withTrackID:))

Returns a track that contains the specified identifier.

[`tracks(withMediaType:)`](/documentation/AVFoundation/AVMutableComposition/tracks(withMediaType:))

Returns tracks that contain media of a specified type.

[`tracks(withMediaCharacteristic:)`](/documentation/AVFoundation/AVMutableComposition/tracks(withMediaCharacteristic:))

Returns tracks that contain media of a specified characteristic.

### Managing composition tracks

[`mutableTrack(compatibleWith:)`](/documentation/AVFoundation/AVMutableComposition/mutableTrack(compatibleWith:))

Returns a composition track into which you can insert any time range of the specified asset track.

[`addMutableTrack(withMediaType:preferredTrackID:)`](/documentation/AVFoundation/AVMutableComposition/addMutableTrack(withMediaType:preferredTrackID:))

Adds an empty track to a composition.

[`removeTrack(_:)`](/documentation/AVFoundation/AVMutableComposition/removeTrack(_:))

Removes a specified track from the composition.

### Managing Cinematic tracks

[`addTracks(for:preferredStartingTrackID:)`](/documentation/AVFoundation/AVMutableComposition/addTracks(for:preferredStartingTrackID:))

[`addTracksForCinematicAssetInfo:preferredStartingTrackID:`](/documentation/AVFoundation/AVMutableComposition/addTracksForCinematicAssetInfo:preferredStartingTrackID:)

Adds a group of empty tracks associated with a cinematic asset to a mutable composition.

### Managing time ranges

[`removeTimeRange(_:)`](/documentation/AVFoundation/AVMutableComposition/removeTimeRange(_:))

Removes a specified time range from all tracks of the composition.

[`scaleTimeRange(_:toDuration:)`](/documentation/AVFoundation/AVMutableComposition/scaleTimeRange(_:toDuration:))

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

[`insertEmptyTimeRange(_:)`](/documentation/AVFoundation/AVMutableComposition/insertEmptyTimeRange(_:))

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

[`insertTimeRange(_:of:at:completionHandler:)`](/documentation/AVFoundation/AVMutableComposition/insertTimeRange(_:of:at:completionHandler:))

Inserts all tracks of an asset for a time range into a composition.

[`insertTimeRange(_:of:at:)`](/documentation/AVFoundation/AVMutableComposition/insertTimeRange(_:of:at:))

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

### Configuring video size

[`naturalSize`](/documentation/AVFoundation/AVMutableComposition/naturalSize)

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

### Instance methods

[`insertTimeRange(_:of:at:isolation:)`](/documentation/AVFoundation/AVMutableComposition/insertTimeRange(_:of:at:isolation:))



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)