# ChunkExtractor

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

*** ** * ** ***


```
@UnstableApi
public interface ChunkExtractor
```

<br />

Known direct subclasses [BundledChunkExtractor](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor), [MediaParserChunkExtractor](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor` implementation that uses ExoPlayer app-bundled `https://developer.android.com/reference/androidx/media3/extractor/Extractor`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor` implemented on top of the platform's `https://developer.android.com/reference/android/media/MediaParser.html`. |

*** ** * ** ***

Extracts samples and track `https://developer.android.com/reference/androidx/media3/common/Format` from chunks.

The `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider` passed to `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor#init(androidx.media3.exoplayer.source.chunk.ChunkExtractor.TrackOutputProvider,long,long)` provides the `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` that receive the extracted data.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` Creates `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor` instances. |
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider` Provides `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` instances to be written to during extraction. |

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor#getChunkIndex()()` Returns the `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` most recently obtained from the chunks, or null if a `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` has not been obtained. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable Format[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor#getSampleFormats()()` Returns the sample `https://developer.android.com/reference/androidx/media3/common/Format`s for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor#init(androidx.media3.exoplayer.source.chunk.ChunkExtractor.TrackOutputProvider,long,long)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider trackOutputProvider, long startTimeUs, long endTimeUs )` Initializes the wrapper to output to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s provided by the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider`, and configures the extractor to receive data from a new chunk. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor#read(androidx.media3.extractor.ExtractorInput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input)` Reads from the given `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor#release()()` Releases any held resources. |

## Public methods

### getChunkIndex

```
abstract @Nullable ChunkIndex getChunkIndex()
```

Returns the `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` most recently obtained from the chunks, or null if a `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` has not been obtained.

### getSampleFormats

```
abstract @Nullable Format[] getSampleFormats()
```

Returns the sample `https://developer.android.com/reference/androidx/media3/common/Format`s for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks.

### init

```
abstract void init(
    @Nullable ChunkExtractor.TrackOutputProvider trackOutputProvider,
    long startTimeUs,
    long endTimeUs
)
```

Initializes the wrapper to output to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s provided by the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider`, and configures the extractor to receive data from a new chunk.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider trackOutputProvider` | The provider of `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s that will receive sample data. |
| `long startTimeUs` | The start position in the new chunk, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to output samples from the start of the chunk. |
| `long endTimeUs` | The end position in the new chunk, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to output samples to the end of the chunk. |

### read

```
abstract boolean read(ExtractorInput input)
```

Reads from the given `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | The input to read from. |

| Returns |
|---|---|
| `boolean` | Whether there is any data left to extract. Returns false if the end of input has been reached. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from or parsing the input. |

### release

```
abstract void release()
```

Releases any held resources.