<!--
{
  "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.

[`+  compositionWithURLAssetInitializationOptions:`](/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.

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

Loads a track that contains the specified identifier.

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

Loads tracks that contain media of a specified type.

[`-  loadTracksWithMediaCharacteristic: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.

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

Returns a track that contains the specified identifier.

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

Returns tracks that contain media of a specified type.

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

Returns tracks that contain media of a specified characteristic.

### Managing composition tracks

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

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

[`-  addMutableTrackWithMediaType: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:ofAsset:atTime:completionHandler:`](/documentation/AVFoundation/AVMutableComposition/insertTimeRange(_:of:at:completionHandler:))

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

[`-  insertTimeRange:ofAsset:atTime:error:`](/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:))

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`NSMutableCopying`](/documentation/Foundation/NSMutableCopying)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`AVAsynchronousKeyValueLoading`](/documentation/AVFoundation/AVAsynchronousKeyValueLoading)

### Inherits From

[`AVComposition`](/documentation/AVFoundation/AVComposition)

---

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)