# Track

Artifact: [androidx.media3:media3-extractor](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/extractor/mp4/Track.java+class:androidx.media3.extractor.mp4.Track)

*** ** * ** ***


```
@UnstableApi
public final class Track
```

<br />

*** ** * ** ***

Encapsulates information describing an MP4 track.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Builder` Builder for `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track`. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Transformation` The transformation to apply to samples in the track, if any. |

| ### Constants |
|---|---|
| `static final long` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TIMESCALE_UNSET() = -1` An unset or unknown timescale. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TRANSFORMATION_CEA608_CDAT() = 1` A transformation for caption samples in cdat atoms. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TRANSFORMATION_MEBX_UNBOX() = 2` A transformation for boxed metadata samples in `mebx` tracks, extracting the box payload matching the target `local_key_id`. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TRANSFORMATION_NONE() = 0` A no-op sample transformation. |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#chapterTrackId()` The identifier of the associated chapter track, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if there is none. |
| `final long` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#durationUs()` The duration of the track in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/ImmutableLongArray.html` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#editListDurations()` Durations of edit list segments in the `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#movieTimescale()`, or ` null` if there is no edit list. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/ImmutableLongArray.html` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#editListMediaTimes()` Media times for edit list segments in the `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#timescale()`, or ` null` if there is no edit list. |
| `final https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#format()` The format. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#id()` The track identifier. |
| `final long` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#mediaDurationUs()` The duration of the media in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `final long` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#movieTimescale()` The movie timescale, or `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TIMESCALE_UNSET()` if unknown. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#nalUnitLengthFieldLength()` The length in bytes of the NALUnitLength field in each sample. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Transformation https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#sampleTransformation()` One of `TRANSFORMATION_*`. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#shouldBeExposed()` Whether the track should be exposed to the player. |
| `final long` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#timescale()` The track timescale, defined as the number of time units that pass in one second, or `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TIMESCALE_UNSET()` if unknown. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/C.TrackType https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#type()` One of `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_AUDIO()`, `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_VIDEO()` and `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_TEXT()`. |

| ### Public constructors |
|---|
| `[Track](https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#Track(int,int,long,long,long,long,androidx.media3.common.Format,int,androidx.media3.extractor.mp4.TrackEncryptionBox[],int,long[],long[],boolean,int))( int id, @https://developer.android.com/reference/androidx/media3/common/C.TrackType int type, long timescale, long movieTimescale, long durationUs, long mediaDurationUs, https://developer.android.com/reference/androidx/media3/common/Format format, @https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Transformation int sampleTransformation, @https://developer.android.com/reference/androidx/annotation/Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes, int nalUnitLengthFieldLength, @https://developer.android.com/reference/androidx/annotation/Nullable long[] editListDurations, @https://developer.android.com/reference/androidx/annotation/Nullable long[] editListMediaTimes, boolean shouldBeExposed, int chapterTrackId )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Builder` instead. <br /> |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Builder` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#buildUpon()()` Returns a new `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Builder` initialized with the values of this instance. |
| `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track` | `[copyWithFormat](https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#copyWithFormat(androidx.media3.common.Format))(https://developer.android.com/reference/androidx/media3/common/Format format)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#buildUpon()` instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track` | `[copyWithoutEditLists](https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#copyWithoutEditLists())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#buildUpon()` instead. <br /> |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#getSampleDescriptionEncryptionBox(int)(int sampleDescriptionIndex)` Returns the `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox` for the given sample description index. |

## Constants

### TIMESCALE_UNSET

```
public static final long TIMESCALE_UNSET = -1
```

An unset or unknown timescale.

### TRANSFORMATION_CEA608_CDAT

```
public static final int TRANSFORMATION_CEA608_CDAT = 1
```

A transformation for caption samples in cdat atoms.

### TRANSFORMATION_MEBX_UNBOX

```
public static final int TRANSFORMATION_MEBX_UNBOX = 2
```

A transformation for boxed metadata samples in `mebx` tracks, extracting the box payload matching the target `local_key_id`.

### TRANSFORMATION_NONE

```
public static final int TRANSFORMATION_NONE = 0
```

A no-op sample transformation.

## Public fields

### chapterTrackId

```
public final int chapterTrackId
```

The identifier of the associated chapter track, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if there is none.

### durationUs

```
public final long durationUs
```

The duration of the track in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown.

### editListDurations

```
public final @Nullable ImmutableLongArray editListDurations
```

Durations of edit list segments in the `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#movieTimescale()`, or `
null` if there is no edit list.

### editListMediaTimes

```
public final @Nullable ImmutableLongArray editListMediaTimes
```

Media times for edit list segments in the `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#timescale()`, or `
null` if there is no edit list.

### format

```
public final Format format
```

The format.

### id

```
public final int id
```

The track identifier.

### mediaDurationUs

```
public final long mediaDurationUs
```

The duration of the media in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown.

### movieTimescale

```
public final long movieTimescale
```

The movie timescale, or `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TIMESCALE_UNSET()` if unknown.

### nalUnitLengthFieldLength

```
public final int nalUnitLengthFieldLength
```

The length in bytes of the NALUnitLength field in each sample. 0 for tracks that don't use length-delimited NAL units.

### sampleTransformation

```
@Track.Transformation
public final int sampleTransformation
```

One of `TRANSFORMATION_*`. Defines the transformation to apply before outputting each sample.

### shouldBeExposed

```
public final boolean shouldBeExposed
```

Whether the track should be exposed to the player.

### timescale

```
public final long timescale
```

The track timescale, defined as the number of time units that pass in one second, or `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#TIMESCALE_UNSET()` if unknown.

### type

```
@C.TrackType
public final int type
```

One of `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_AUDIO()`, `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_VIDEO()` and `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_TEXT()`.

## Public constructors

### Track

```
public [Track](https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#Track(int,int,long,long,long,long,androidx.media3.common.Format,int,androidx.media3.extractor.mp4.TrackEncryptionBox[],int,long[],long[],boolean,int))(
    int id,
    @C.TrackType int type,
    long timescale,
    long movieTimescale,
    long durationUs,
    long mediaDurationUs,
    Format format,
    @Track.Transformation int sampleTransformation,
    @Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes,
    int nalUnitLengthFieldLength,
    @Nullable long[] editListDurations,
    @Nullable long[] editListMediaTimes,
    boolean shouldBeExposed,
    int chapterTrackId
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Builder` instead.

## Public methods

### buildUpon

```
public Track.Builder buildUpon()
```

Returns a new `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track.Builder` initialized with the values of this instance.

### copyWithFormat

```
public Track [copyWithFormat](https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#copyWithFormat(androidx.media3.common.Format))(Format format)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#buildUpon()` instead.

### copyWithoutEditLists

```
public Track [copyWithoutEditLists](https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#copyWithoutEditLists())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/extractor/mp4/Track#buildUpon()` instead.

### getSampleDescriptionEncryptionBox

```
public @Nullable TrackEncryptionBox getSampleDescriptionEncryptionBox(int sampleDescriptionIndex)
```

Returns the `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox` for the given sample description index.

| Parameters |
|---|---|
| `int sampleDescriptionIndex` | The given sample description index |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox` | The `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox` for the given sample description index. Maybe null if no such entry exists. |