# VideoEncoderSettings.Builder

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

*** ** * ** ***


```
class VideoEncoderSettings.Builder
```

<br />

*** ** * ** ***

Builds `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#Builder()()` Creates a new instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#build()()` Builds the instance. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setBitrate(int)(bitrate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#bitrate()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setBitrateMode(int)(@https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.BitrateMode bitrateMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#bitrateMode()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setComplexity(int)(complexity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the encoding complexity. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setEncoderPerformanceParameters(int,int)(operatingRate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, priority: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets encoding operating rate and priority. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setEncodingProfileLevel(int,int)(encodingProfile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, encodingLevel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#profile()` and `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#level()`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setMaxBFrames(int)(maxBFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the maximum number of B frames allowed between I or P frames in the produced video. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setRepeatPreviousFrameIntervalUs(long)(repeatPreviousFrameIntervalUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the threshold duration between input frames beyond which to repeat the previous frame if no new frame has been received, in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setTemporalLayers(int,int)( numNonBidirectionalLayers: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, numBidirectionalLayers: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets the number of temporal layers to request from the video encoder. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder#setiFrameIntervalSeconds(float)(iFrameIntervalSeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#iFrameIntervalSeconds()`. |

## Public constructors

### Builder

```
Builder()
```

Creates a new instance.

## Public functions

### build

```
fun build(): VideoEncoderSettings!
```

Builds the instance.

### setBitrate

```
@CanIgnoreReturnValue
fun setBitrate(bitrate: Int): VideoEncoderSettings.Builder!
```

Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#bitrate()`. The default value is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`.

| Parameters |
|---|---|
| `bitrate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#bitrate()` in bits per second. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setBitrateMode

```
@CanIgnoreReturnValue
fun setBitrateMode(@VideoEncoderSettings.BitrateMode bitrateMode: Int): VideoEncoderSettings.Builder!
```

Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#bitrateMode()`. The default value is `
MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR`.

Value must be in `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.BitrateMode`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.BitrateMode bitrateMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#bitrateMode()`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setComplexity

```
@CanIgnoreReturnValue
fun setComplexity(complexity: Int): VideoEncoderSettings.Builder!
```

Sets the encoding complexity. The default value is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()` which indicates that no `https://developer.android.com/reference/android/media/MediaFormat.html#KEY_COMPLEXITY` will be set for the encoder.

The valid range of values depends on the encoder, and is exposed by `https://developer.android.com/reference/android/media/MediaCodecInfo.EncoderCapabilities.html#getComplexityRange()`.

| Parameters |
|---|---|
| `complexity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/android/media/MediaFormat.html#KEY_COMPLEXITY`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setEncoderPerformanceParameters

```
@CanIgnoreReturnValue
fun setEncoderPerformanceParameters(operatingRate: Int, priority: Int): VideoEncoderSettings.Builder!
```

Sets encoding operating rate and priority. The default values are `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`, which is treated as configuring the encoder for maximum throughput.

To disable the configuration for either operating rate or priority, use `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#RATE_UNSET()` for that argument.

| Parameters |
|---|---|
| `operatingRate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/android/media/MediaFormat.html#KEY_OPERATING_RATE` in frames per second. |
| `priority: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/android/media/MediaFormat.html#KEY_PRIORITY`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setEncodingProfileLevel

```
@CanIgnoreReturnValue
fun setEncodingProfileLevel(encodingProfile: Int, encodingLevel: Int): VideoEncoderSettings.Builder!
```

Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#profile()` and `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#level()`. The default values are both `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`.

The value must be one of the values defined in `https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html`, or `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`.

Profile settings will be ignored when using `https://developer.android.com/reference/kotlin/androidx/media3/transformer/DefaultEncoderFactory` and encoding to H264.

| Parameters |
|---|---|
| `encodingProfile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#profile()`. |
| `encodingLevel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#level()`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setMaxBFrames

```
@CanIgnoreReturnValue
fun setMaxBFrames(maxBFrames: Int): VideoEncoderSettings.Builder!
```

Sets the maximum number of B frames allowed between I or P frames in the produced video. The default value is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()` which means that B frame encoding is disabled.

| Parameters |
|---|---|
| `maxBFrames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the `https://developer.android.com/reference/android/media/MediaFormat.html#KEY_MAX_B_FRAMES` allowed. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setRepeatPreviousFrameIntervalUs

```
@CanIgnoreReturnValue
fun setRepeatPreviousFrameIntervalUs(repeatPreviousFrameIntervalUs: Long): VideoEncoderSettings.Builder!
```

Sets the threshold duration between input frames beyond which to repeat the previous frame if no new frame has been received, in microseconds. The default value is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`, which means that frames are not automatically repeated.

| Parameters |
|---|---|
| `repeatPreviousFrameIntervalUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The `https://developer.android.com/reference/android/media/MediaFormat.html#KEY_REPEAT_PREVIOUS_FRAME_AFTER`, in microseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setTemporalLayers

```
@CanIgnoreReturnValue
fun setTemporalLayers(
    numNonBidirectionalLayers: Int,
    numBidirectionalLayers: Int
): VideoEncoderSettings.Builder!
```

Sets the number of temporal layers to request from the video encoder.

The default value for both parameters is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()` which indicates that no `https://developer.android.com/reference/android/media/MediaFormat.html#KEY_TEMPORAL_LAYERING` will be set for the encoder.

| Parameters |
|---|---|
| `numNonBidirectionalLayers: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the number of predictive layers to have. This value must be greater than or equal to zero, or `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()` if `numBidirectionalLayers` is also `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`. A value of '0' explicitly requests no temporal layers from the encoder, in which case `numBidirectionalLayers` must be '0' or `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`. |
| `numBidirectionalLayers: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the number of bi-directional layers to have. This value must be greater than or equal to zero, or `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()` if `numNonBidirectionalLayers` is '0' or `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#NO_VALUE()`. A value greater than 1 constructs a hierarchical-B coding structure. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |

### setiFrameIntervalSeconds

```
@CanIgnoreReturnValue
fun setiFrameIntervalSeconds(iFrameIntervalSeconds: Float): VideoEncoderSettings.Builder!
```

Sets `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#iFrameIntervalSeconds()`. The default value is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#DEFAULT_I_FRAME_INTERVAL_SECONDS()`.

| Parameters |
|---|---|
| `iFrameIntervalSeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings#iFrameIntervalSeconds()`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/VideoEncoderSettings.Builder!` | This builder. |