# Extractor

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/Extractor.java+class:androidx.media3.extractor.Extractor)

*** ** * ** ***


```
@UnstableApi
public interface Extractor
```

<br />

Known direct subclasses [Ac3Extractor](https://developer.android.com/reference/androidx/media3/extractor/ts/Ac3Extractor), [Ac4Extractor](https://developer.android.com/reference/androidx/media3/extractor/ts/Ac4Extractor), [AdtsExtractor](https://developer.android.com/reference/androidx/media3/extractor/ts/AdtsExtractor), [AmrExtractor](https://developer.android.com/reference/androidx/media3/extractor/amr/AmrExtractor), [AviExtractor](https://developer.android.com/reference/androidx/media3/extractor/avi/AviExtractor), [AvifExtractor](https://developer.android.com/reference/androidx/media3/extractor/avif/AvifExtractor), [BmpExtractor](https://developer.android.com/reference/androidx/media3/extractor/bmp/BmpExtractor), [FlacExtractor](https://developer.android.com/reference/androidx/media3/extractor/flac/FlacExtractor), [FlvExtractor](https://developer.android.com/reference/androidx/media3/extractor/flv/FlvExtractor), [ForwardingExtractor](https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractor), [FragmentedMp4Extractor](https://developer.android.com/reference/androidx/media3/extractor/mp4/FragmentedMp4Extractor), [HeifExtractor](https://developer.android.com/reference/androidx/media3/extractor/heif/HeifExtractor), [JpegExtractor](https://developer.android.com/reference/androidx/media3/extractor/jpeg/JpegExtractor), [MatroskaExtractor](https://developer.android.com/reference/androidx/media3/extractor/mkv/MatroskaExtractor), [Mp3Extractor](https://developer.android.com/reference/androidx/media3/extractor/mp3/Mp3Extractor), [Mp4Extractor](https://developer.android.com/reference/androidx/media3/extractor/mp4/Mp4Extractor), [OggExtractor](https://developer.android.com/reference/androidx/media3/extractor/ogg/OggExtractor), [PngExtractor](https://developer.android.com/reference/androidx/media3/extractor/png/PngExtractor), [PsExtractor](https://developer.android.com/reference/androidx/media3/extractor/ts/PsExtractor), [SingleSampleExtractor](https://developer.android.com/reference/androidx/media3/extractor/SingleSampleExtractor), [SubtitleExtractor](https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleExtractor), [SubtitleTranscodingExtractor](https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleTranscodingExtractor), [TsExtractor](https://developer.android.com/reference/androidx/media3/extractor/ts/TsExtractor), [WavExtractor](https://developer.android.com/reference/androidx/media3/extractor/wav/WavExtractor), [WebpExtractor](https://developer.android.com/reference/androidx/media3/extractor/webp/WebpExtractor), [WebvttExtractor](https://developer.android.com/reference/androidx/media3/exoplayer/hls/WebvttExtractor)

|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ts/Ac3Extractor` | Extracts data from (E-)AC-3 bitstreams. |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/Ac4Extractor` | Extracts data from AC-4 bitstreams. |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/AdtsExtractor` | Extracts data from AAC bit streams with ADTS framing. |
| `https://developer.android.com/reference/androidx/media3/extractor/amr/AmrExtractor` | Extracts data from the AMR containers format (either AMR or AMR-WB). |
| `https://developer.android.com/reference/androidx/media3/extractor/avi/AviExtractor` | Extracts data from the AVI container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/avif/AvifExtractor` | Extracts data from the AVIF (.avif) container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/bmp/BmpExtractor` | Extracts data from the BMP container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/flac/FlacExtractor` | Extracts data from FLAC container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/flv/FlvExtractor` | Extracts data from the FLV container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractor` | An overridable `https://developer.android.com/reference/androidx/media3/extractor/Extractor` implementation which forwards all methods to another `https://developer.android.com/reference/androidx/media3/extractor/Extractor`. |
| `https://developer.android.com/reference/androidx/media3/extractor/mp4/FragmentedMp4Extractor` | Extracts data from the FMP4 container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/heif/HeifExtractor` | Extracts data from the HEIF/HEIC container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/jpeg/JpegExtractor` | Extracts data from the JPEG container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/mkv/MatroskaExtractor` | Extracts data from the Matroska and WebM container formats. |
| `https://developer.android.com/reference/androidx/media3/extractor/mp3/Mp3Extractor` | Extracts data from the MP3 container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/mp4/Mp4Extractor` | Extracts data from the MP4 container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/ogg/OggExtractor` | Extracts data from the Ogg container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/png/PngExtractor` | Extracts data from the PNG container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/PsExtractor` | Extracts data from the MPEG-2 PS container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/SingleSampleExtractor` | Extracts data by loading all the bytes into one sample. |
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleExtractor` | Generic extractor for extracting subtitles from various subtitle formats. |
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleTranscodingExtractor` | **This class is deprecated.** Use `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleTranscodingExtractorOutput` directly from within an existing `https://developer.android.com/reference/androidx/media3/extractor/Extractor` implementation instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/TsExtractor` | Extracts data from the MPEG-2 TS container format. |
| `https://developer.android.com/reference/androidx/media3/extractor/wav/WavExtractor` | Extracts data from WAV byte streams. |
| `https://developer.android.com/reference/androidx/media3/extractor/webp/WebpExtractor` | Extracts data from the WEBP container format. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/WebvttExtractor` | A special purpose extractor for WebVTT content in HLS. |

*** ** * ** ***

Extracts media data from a container format.

## Summary

| ### Nested types |
|---|
| `@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/Extractor.ReadResult` Result values that can be returned by `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)`. |

| ### Constants |
|---|---|
| `default static final int` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#RESULT_CONTINUE() = 0` Returned by `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` if the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` passed to the next `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` is required to provide data continuing from the position in the stream reached by the returning call. |
| `default static final int` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#RESULT_END_OF_INPUT() = -1` Returned by `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` if the end of the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` was reached. |
| `default static final int` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#RESULT_SEEK() = 1` Returned by `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` if the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` passed to the next `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` is required to provide data starting from a specified position in the stream. |

| ### Public methods |
|---|---|
| `default https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/extractor/SniffFailure>` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#getSniffFailureDetails()()` Returns additional details about the last call to `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)`. |
| `default https://developer.android.com/reference/androidx/media3/extractor/Extractor` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/SideEffectFree.html https://developer.android.com/reference/androidx/media3/extractor/Extractor#getUnderlyingImplementation()()` Returns the 'real' `Extractor` implementation if this is a delegating instance, or ` this` if this instance does the extraction directly without delegating (the default behaviour). |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#init(androidx.media3.extractor.ExtractorOutput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput output)` Initializes the extractor with an `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput`. |
| `abstract int` | `@https://developer.android.com/reference/androidx/media3/extractor/Extractor.ReadResult https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input, https://developer.android.com/reference/androidx/media3/extractor/PositionHolder seekPosition)` Extracts data read from a provided `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#release()()` Releases all kept resources. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#seek(long,long)(long position, long timeUs)` Notifies the extractor that a seek has occurred. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input)` Returns whether this extractor can extract samples from the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`, which must provide data from the start of the stream. |

## Constants

### RESULT_CONTINUE

```
default static final int RESULT_CONTINUE = 0
```

Returned by `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` if the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` passed to the next `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` is required to provide data continuing from the position in the stream reached by the returning call.

### RESULT_END_OF_INPUT

```
default static final int RESULT_END_OF_INPUT = -1
```

Returned by `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` if the end of the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` was reached. Equal to `https://developer.android.com/reference/androidx/media3/common/C#RESULT_END_OF_INPUT()`.

### RESULT_SEEK

```
default static final int RESULT_SEEK = 1
```

Returned by `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` if the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` passed to the next `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` is required to provide data starting from a specified position in the stream.

## Public methods

### getSniffFailureDetails

```
default List<SniffFailure> getSniffFailureDetails()
```

Returns additional details about the last call to `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)`. The returned list may be empty if no additional details are available, or the last `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` call returned `
true`.

This only contains details that were discovered before `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` returned `
false`, it is not an exhaustive list of issues which, if resolved, would cause the file to be successfully sniffed.

### getUnderlyingImplementation

```
@SideEffectFree
default Extractor getUnderlyingImplementation()
```

Returns the 'real' `Extractor` implementation if this is a delegating instance, or `
this` if this instance does the extraction directly without delegating (the default behaviour).

`Extractor` implementations that operate by delegating to another `Extractor` should override this method to return that delegate.

### init

```
abstract void init(ExtractorOutput output)
```

Initializes the extractor with an `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput`. Called at most once.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput output` | An `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput` to receive extracted data. |

### read

```
@Extractor.ReadResult
abstract int read(ExtractorInput input, PositionHolder seekPosition)
```

Extracts data read from a provided `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`. Must not be called before `https://developer.android.com/reference/androidx/media3/extractor/Extractor#init(androidx.media3.extractor.ExtractorOutput)`.

A single call to this method will block until some progress has been made, but will not block for longer than this. Hence each call will consume only a small amount of input data.

In the common case, `https://developer.android.com/reference/androidx/media3/extractor/Extractor#RESULT_CONTINUE()` is returned to indicate that the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` passed to the next read is required to provide data continuing from the position in the stream reached by the returning call. If the extractor requires data to be provided from a different position, then that position is set in `seekPosition` and `https://developer.android.com/reference/androidx/media3/extractor/Extractor#RESULT_SEEK()` is returned. If the extractor reached the end of the data provided by the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`, then `https://developer.android.com/reference/androidx/media3/extractor/Extractor#RESULT_END_OF_INPUT()` is returned.

When this method throws an `https://developer.android.com/reference/java/io/IOException.html`, extraction may continue by providing an `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` with an unchanged `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#getPosition()` to a subsequent call to this method.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | The `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` from which data should be read. |
| `https://developer.android.com/reference/androidx/media3/extractor/PositionHolder seekPosition` | If `https://developer.android.com/reference/androidx/media3/extractor/Extractor#RESULT_SEEK()` is returned, this holder is updated to hold the position of the required data. |

| Returns |
|---|---|
| `int` | One of the `RESULT_` values defined in this interface. |

| 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 all kept resources.

### seek

```
abstract void seek(long position, long timeUs)
```

Notifies the extractor that a seek has occurred.

Following a call to this method, the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` passed to the next invocation of `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)` is required to provide data starting from `
position` in the stream. Valid random access positions are the start of the stream and positions that can be obtained from any `https://developer.android.com/reference/androidx/media3/extractor/SeekMap` passed to the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput`.

| Parameters |
|---|---|
| `long position` | The byte offset in the stream from which data will be provided. |
| `long timeUs` | The seek time in microseconds. |

### sniff

```
abstract boolean sniff(ExtractorInput input)
```

Returns whether this extractor can extract samples from the `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`, which must provide data from the start of the stream.

If `true` is returned, the `input`'s reading position may have been modified. Otherwise, only its peek position may have been modified.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | The `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` from which data should be peeked/read. |

| Returns |
|---|---|
| `boolean` | Whether this extractor can read the provided input. |

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