# VideoDecoderOutputBuffer

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

*** ** * ** ***


```
@UnstableApi
public class VideoDecoderOutputBuffer extends DecoderOutputBuffer
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [androidx.media3.decoder.Buffer](https://developer.android.com/reference/androidx/media3/decoder/Buffer) |||
|   | ↳ | [androidx.media3.decoder.DecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer) ||
|   |   | ↳ | [androidx.media3.decoder.VideoDecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer) |

*** ** * ** ***

Video decoder output buffer containing video frame data.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#COLORSPACE_BT2020() = 3` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#COLORSPACE_BT601() = 1` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#COLORSPACE_BT709() = 2` |
| `static final int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#COLORSPACE_UNKNOWN() = 0` |

| ### Public fields |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#colorspace()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/nio/ByteBuffer.html` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#data()` RGB buffer for RGB mode. |
| `long` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#decoderPrivate()` Decoder private data. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#format()` The format of the input from which this output buffer was decoded. |
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#height()` |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/C.VideoOutputMode https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#mode()` Output mode. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/nio/ByteBuffer.html` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#supplementalData()` Supplemental data related to the output frame, if `https://developer.android.com/reference/androidx/media3/decoder/Buffer#hasSupplementalData()` returns true. |
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#uvStride()` |
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#width()` |
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#yStride()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable ByteBuffer[]` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#yuvPlanes()` YUV planes for YUV mode. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable int[]` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#yuvStrides()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#VideoDecoderOutputBuffer(androidx.media3.decoder.DecoderOutputBuffer.Owner<androidx.media3.decoder.VideoDecoderOutputBuffer>)( https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer.Owner<https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer> owner )` Creates VideoDecoderOutputBuffer. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#init(long,int,java.nio.ByteBuffer)( long timeUs, @https://developer.android.com/reference/androidx/media3/common/C.VideoOutputMode int mode, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/nio/ByteBuffer.html supplementalData )` Initializes the buffer. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#initForOffsetFrames(int,int,int,int,int,int,int)( int offset, int width, int height, int yStride, int uvStride, int colorspace, int alignedHeight )` |
| `void` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#initForPrivateFrame(int,int)(int width, int height)` Configures the buffer for the given frame dimensions when passing actual frame data via `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#decoderPrivate()`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#initForYuvFrame(int,int,int,int,int)( int width, int height, int yStride, int uvStride, int colorspace )` Resizes the buffer based on the given stride. |
| `void` | `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#release()()` Releases the output buffer for reuse. |

### Inherited fields

From [androidx.media3.decoder.DecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer) `boolean` `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#shouldBeSkipped()`

Whether this buffer should be skipped, usually because the decoding process generated no data or invalid data.
`int` `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#skippedOutputBufferCount()`

The number of buffers immediately prior to this one that were skipped in the `https://developer.android.com/reference/androidx/media3/decoder/Decoder`.
`long` `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#timeUs()`

The presentation timestamp for the buffer, in microseconds.

### Inherited methods

From [androidx.media3.decoder.Buffer](https://developer.android.com/reference/androidx/media3/decoder/Buffer) `final void` `https://developer.android.com/reference/androidx/media3/decoder/Buffer#addFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)`

Adds the `flag` to this buffer's flags.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/Buffer#clearFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)`

Removes the `flag` from this buffer's flags, if it is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#getFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)`

Returns whether the specified flag has been set on this buffer.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#hasSupplementalData()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isEndOfStream()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isFirstSample()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_FIRST_SAMPLE()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isKeyFrame()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_KEY_FRAME()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isLastSample()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_LAST_SAMPLE()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#notDependedOn()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_NOT_DEPENDED_ON()` flag is set.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/Buffer#setFlags(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flags)`

Replaces this buffer's flags with `flags`.
From [androidx.media3.decoder.DecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer) `void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#clear()()`

Clears the buffer.

## Constants

### COLORSPACE_BT2020

```
public static final int COLORSPACE_BT2020 = 3
```

### COLORSPACE_BT601

```
public static final int COLORSPACE_BT601 = 1
```

### COLORSPACE_BT709

```
public static final int COLORSPACE_BT709 = 2
```

### COLORSPACE_UNKNOWN

```
public static final int COLORSPACE_UNKNOWN = 0
```

## Public fields

### colorspace

```
public int colorspace
```

### data

```
public @Nullable ByteBuffer data
```

RGB buffer for RGB mode.

### decoderPrivate

```
public long decoderPrivate
```

Decoder private data. Used from native code.

### format

```
public @Nullable Format format
```

The format of the input from which this output buffer was decoded.

### height

```
public int height
```

### mode

```
@C.VideoOutputMode
public int mode
```

Output mode.

### supplementalData

```
public @Nullable ByteBuffer supplementalData
```

Supplemental data related to the output frame, if `https://developer.android.com/reference/androidx/media3/decoder/Buffer#hasSupplementalData()` returns true. If present, the buffer is populated with supplemental data from position 0 to its limit.

### uvStride

```
public int uvStride
```

### width

```
public int width
```

### yStride

```
public int yStride
```

### yuvPlanes

```
public @Nullable ByteBuffer[] yuvPlanes
```

YUV planes for YUV mode.

### yuvStrides

```
public @Nullable int[] yuvStrides
```

## Public constructors

### VideoDecoderOutputBuffer

```
public VideoDecoderOutputBuffer(
    DecoderOutputBuffer.Owner<VideoDecoderOutputBuffer> owner
)
```

Creates VideoDecoderOutputBuffer.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer.Owner<https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer> owner` | Buffer owner. |

## Public methods

### init

```
public void init(
    long timeUs,
    @C.VideoOutputMode int mode,
    @Nullable ByteBuffer supplementalData
)
```

Initializes the buffer.

| Parameters |
|---|---|
| `long timeUs` | The presentation timestamp for the buffer, in microseconds. |
| `@https://developer.android.com/reference/androidx/media3/common/C.VideoOutputMode int mode` | The output mode. One of `https://developer.android.com/reference/androidx/media3/common/C#VIDEO_OUTPUT_MODE_NONE()`, `https://developer.android.com/reference/androidx/media3/common/C#VIDEO_OUTPUT_MODE_YUV()` and `https://developer.android.com/reference/androidx/media3/common/C#VIDEO_OUTPUT_MODE_SURFACE_YUV()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/nio/ByteBuffer.html supplementalData` | Supplemental data associated with the frame, or `null` if not present. It is safe to reuse the provided buffer after this method returns. |

### initForOffsetFrames

```
public boolean initForOffsetFrames(
    int offset,
    int width,
    int height,
    int yStride,
    int uvStride,
    int colorspace,
    int alignedHeight
)
```

### initForPrivateFrame

```
public void initForPrivateFrame(int width, int height)
```

Configures the buffer for the given frame dimensions when passing actual frame data via `https://developer.android.com/reference/androidx/media3/decoder/VideoDecoderOutputBuffer#decoderPrivate()`. Called via JNI after decoding completes.

### initForYuvFrame

```
public boolean initForYuvFrame(
    int width,
    int height,
    int yStride,
    int uvStride,
    int colorspace
)
```

Resizes the buffer based on the given stride. Called via JNI after decoding completes.

| Returns |
|---|---|
| `boolean` | Whether the buffer was resized successfully. |

### release

```
public void release()
```

Releases the output buffer for reuse. Must be called when the buffer is no longer needed.