# ColorConversion

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

*** ** * ** ***


```
@ExperimentalApi
public final class ColorConversion implements GlEffect
```

<br />

*** ** * ** ***

Converts frames from an input color space to an electrical output color space.

Applying this effect last in an effect chain sets the output color space of the video frame processing pipeline.

## Summary

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/effect/ColorConversion` | `https://developer.android.com/reference/androidx/media3/effect/ColorConversion#create(androidx.media3.common.ColorInfo)(https://developer.android.com/reference/androidx/media3/common/ColorInfo outputColorInfo)` Creates an instance that converts frames to `outputColorInfo`. |
| `https://developer.android.com/reference/androidx/media3/effect/GlShaderProgram` | `https://developer.android.com/reference/androidx/media3/effect/ColorConversion#toGlShaderProgram(android.content.Context,boolean)(https://developer.android.com/reference/android/content/Context.html context, boolean useHdr)` Not supported, because the input color space is only known once the pipeline receives frames. |

### Inherited methods

From [androidx.media3.common.Effect](https://developer.android.com/reference/androidx/media3/common/Effect) `long` `https://developer.android.com/reference/androidx/media3/common/Effect#getDurationAfterEffectApplied(long)(long durationUs)`

Returns the expected duration of the output stream when the effect is applied given a input `durationUs`.
From [androidx.media3.effect.GlEffect](https://developer.android.com/reference/androidx/media3/effect/GlEffect) `boolean` `https://developer.android.com/reference/androidx/media3/effect/GlEffect#isNoOp(int,int)(int inputWidth, int inputHeight)`

Returns whether a `https://developer.android.com/reference/androidx/media3/effect/GlEffect` applies no change at every timestamp.

## Public methods

### create

```
public static ColorConversion create(ColorInfo outputColorInfo)
```

Creates an instance that converts frames to `outputColorInfo`.

Supported outputs are BT.2020 with `https://developer.android.com/reference/androidx/media3/common/C#COLOR_TRANSFER_HLG()`, and BT.709 with `https://developer.android.com/reference/androidx/media3/common/C#COLOR_TRANSFER_SRGB()`. Other properties of `outputColorInfo`, such as the `https://developer.android.com/reference/androidx/media3/common/ColorInfo#colorRange()`, do not affect the conversion and are propagated to the output frames unchanged.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/ColorInfo outputColorInfo` | The `https://developer.android.com/reference/androidx/media3/common/ColorInfo` to convert frames to. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/ColorConversion` | A new instance. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `outputColorInfo` is not supported. |

### toGlShaderProgram

```
public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
```

Not supported, because the input color space is only known once the pipeline receives frames.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | Always. This effect is only supported by `https://developer.android.com/reference/androidx/media3/effect/DefaultGlFrameProcessor`. |