# Frame

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

*** ** * ** ***

<br />

```
@ExperimentalApi
public interface Frame
```

<br />

Known direct subclasses [HardwareBufferFrame](https://developer.android.com/reference/androidx/media3/common/video/HardwareBufferFrame)

|---|---|
| `https://developer.android.com/reference/androidx/media3/common/video/HardwareBufferFrame` | A `https://developer.android.com/reference/androidx/media3/common/video/Frame` backed by a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |

*** ** * ** ***

Holds a frame of video data.

Pixel data is accessible via subtypes.

## Summary

| ### Nested types |
|---|
| `@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/LongDef(flag = true, value = ) public annotation https://developer.android.com/reference/androidx/media3/common/video/Frame.Usage` Flags that define how `https://developer.android.com/reference/androidx/media3/common/video/Frame` are used. |

| ### Constants |
|---|---|
| `default static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#KEY_DISPLAY_TIME_NS() = "KEY_DISPLAY_TIME_NS"` Metadata key for storing the system time that this frame should be displayed at to maintain A/V sync. |
| `default static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#KEY_PRESENTATION_TIME_US() = "KEY_PRESENTATION_TIME_US"` Metadata key for storing the composition presentation time of this frame, in microseconds. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_COMPOSER_OVERLAY() = 2048` The frame will be used as a hardware composer overlay layer. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_CPU_READ_OFTEN() = 3` The frame will often be read by the CPU. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_CPU_READ_RARELY() = 2` The frame will sometimes be read by the CPU. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_CPU_WRITE_OFTEN() = 48` The frame will often be written to by the CPU. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_CPU_WRITE_RARELY() = 32` The frame will sometimes be written to by the CPU. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_GPU_COLOR_OUTPUT() = 512` The frame will be written to by the GPU. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_GPU_SAMPLED_IMAGE() = 256` The frame will be read from by the GPU. |
| `default static final long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#USAGE_VIDEO_ENCODE() = 65536` The frame will be read by a hardware video encoder. |

| ### Public methods |
|---|---|
| `abstract long` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#getContentTimeUs()()` The time of the frame in the context of the input media in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if it is not set. |
| `abstract https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#getFormat()()` The frame format. |
| `abstract https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableMap.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/media3/common/video/Frame#getMetadata()()` The frame metadata. |

## Constants

### KEY_DISPLAY_TIME_NS

```
default static final String KEY_DISPLAY_TIME_NS = "KEY_DISPLAY_TIME_NS"
```

Metadata key for storing the system time that this frame should be displayed at to maintain A/V sync. The value should be a `Long`.

### KEY_PRESENTATION_TIME_US

```
default static final String KEY_PRESENTATION_TIME_US = "KEY_PRESENTATION_TIME_US"
```

Metadata key for storing the composition presentation time of this frame, in microseconds. The value should be a `Long`.

### USAGE_COMPOSER_OVERLAY

```
default static final long USAGE_COMPOSER_OVERLAY = 2048
```

The frame will be used as a hardware composer overlay layer. That is, it will be displayed using the system compositor via `https://developer.android.com/reference/android/view/SurfaceControl.html`.

### USAGE_CPU_READ_OFTEN

```
default static final long USAGE_CPU_READ_OFTEN = 3
```

The frame will often be read by the CPU.

### USAGE_CPU_READ_RARELY

```
default static final long USAGE_CPU_READ_RARELY = 2
```

The frame will sometimes be read by the CPU.

### USAGE_CPU_WRITE_OFTEN

```
default static final long USAGE_CPU_WRITE_OFTEN = 48
```

The frame will often be written to by the CPU.

### USAGE_CPU_WRITE_RARELY

```
default static final long USAGE_CPU_WRITE_RARELY = 32
```

The frame will sometimes be written to by the CPU.

### USAGE_GPU_COLOR_OUTPUT

```
default static final long USAGE_GPU_COLOR_OUTPUT = 512
```

The frame will be written to by the GPU.

### USAGE_GPU_SAMPLED_IMAGE

```
default static final long USAGE_GPU_SAMPLED_IMAGE = 256
```

The frame will be read from by the GPU.

### USAGE_VIDEO_ENCODE

```
default static final long USAGE_VIDEO_ENCODE = 65536
```

The frame will be read by a hardware video encoder.

## Public methods

### getContentTimeUs

```
abstract long getContentTimeUs()
```

The time of the frame in the context of the input media in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if it is not set.

### getFormat

```
abstract Format getFormat()
```

The frame format.

### getMetadata

```
abstract ImmutableMap<String, Object> getMetadata()
```

The frame metadata.