<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVMutableComposition/addMutableTrack(withMediaType:preferredTrackID:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVMutableComposition(im)addMutableTrackWithMediaType:preferredTrackID:"
  },
  "title" : "addMutableTrack(withMediaType:preferredTrackID:)"
}
-->

# addMutableTrack(withMediaType:preferredTrackID:)

Adds an empty track to a composition.

```
func addMutableTrack(withMediaType mediaType: AVMediaType, preferredTrackID: CMPersistentTrackID) -> AVMutableCompositionTrack?
```

## Parameters

`mediaType`

The media type of the new track.

`preferredTrackID`

The preferred track ID for the new track. The system generates a unique ID if the value you specify isn’t available. If you don’t need to specify a preferred track ID, pass <doc://com.apple.documentation/documentation/CoreMedia/kCMPersistentTrackID_Invalid>, and the system generates an appropriate identifier.

## Return Value

A new mutable composition track.

## Discussion

---

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)