---
title: "addMutableTrack(withMediaType:preferredTrackID:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avmutablecomposition/addmutabletrack(withmediatype:preferredtrackid:)"
---

# addMutableTrack(withMediaType:preferredTrackID:)

Adds an empty track to a composition.

## Declaration

```swift
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

Return Value A new mutable composition track.

## See Also

### Managing composition tracks

- [mutableTrack(compatibleWith:)](avfoundation/avmutablecomposition/mutabletrack(compatiblewith:).md)
- [removeTrack(_:)](avfoundation/avmutablecomposition/removetrack(_:).md)
