> Documentation index: https://developer.android.com/reference/llms.txt

# VideoEncoderConstraintsPresets

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

*** ** * ** ***


```
@ExperimentalApi
class VideoEncoderConstraintsPresets
```

<br />

*** ** * ** ***

Factories for `VideoEncoderConstraints` with presets for common encoding use cases.

Callers can override individual constraints of a preset via `buildUpon`.

## Summary

| ### Public functions |
|---|---|
| `java-static VideoEncoderConstraints!` | `forEditing(width: Int, height: Int, frameRate: Double)` Returns constraints with presets for video editing. |
| `java-static VideoEncoderConstraints!` | `forGalleryExport(width: Int, height: Int, frameRate: Double)` Returns constraints with presets for exporting a video to the device gallery. |
| `java-static VideoEncoderConstraints!` | `forHqCameraRecording(width: Int, height: Int, frameRate: Double)` Returns constraints with presets for high-quality camera recording. |
| `java-static VideoEncoderConstraints!` | `forLiveStreaming( width: Int, height: Int, frameRate: Double, targetMaxBitrate: Int )` Returns constraints with presets for live streaming. |
| `java-static VideoEncoderConstraints!` | `forMessaging( width: Int, height: Int, frameRate: Double, targetMaxBitrate: Int )` Returns constraints with presets for messaging, where fitting within a strict file-size or bitrate limit is the top priority. |
| `java-static VideoEncoderConstraints!` | `forRealTimeCommunication( width: Int, height: Int, frameRate: Double, targetMaxBitrate: Int )` Returns constraints with presets for real-time communication (such as video calling) optimized for minimal latency. |
| `java-static VideoEncoderConstraints!` | `forSocialPosting(width: Int, height: Int, frameRate: Double)` Returns constraints with presets for social media posting. |

## Public functions

### forEditing

```
java-static fun forEditing(width: Int, height: Int, frameRate: Double): VideoEncoderConstraints!
```

Returns constraints with presets for video editing.

The target quality is `QUALITY_LEVEL_VERY_GOOD`. Uses `VBR rate control` with ` B-frames allowed`.

| Parameters |
|---|---|
| `width: Int` | The video width, in pixels. |
| `height: Int` | The video height, in pixels. |
| `frameRate: Double` | The video frame rate, in frames per second. |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `width` or `height` is not positive, or if `frameRate` is not positive and finite. |

### forGalleryExport

```
java-static fun forGalleryExport(width: Int, height: Int, frameRate: Double): VideoEncoderConstraints!
```

Returns constraints with presets for exporting a video to the device gallery.

The target quality is `QUALITY_LEVEL_GOOD`. Uses ` VBR rate control` with ` B-frames allowed`. Currently uses the same presets as `forSocialPosting`, which is a separate use case so that its presets can diverge in the future.

| Parameters |
|---|---|
| `width: Int` | The video width, in pixels. |
| `height: Int` | The video height, in pixels. |
| `frameRate: Double` | The video frame rate, in frames per second. |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `width` or `height` is not positive, or if `frameRate` is not positive and finite. |

### forHqCameraRecording

```
java-static fun forHqCameraRecording(width: Int, height: Int, frameRate: Double): VideoEncoderConstraints!
```

Returns constraints with presets for high-quality camera recording.

The target quality is `QUALITY_LEVEL_NEAR_LOSSLESS`. Uses `VBR rate control` with ` B-frames allowed`.

| Parameters |
|---|---|
| `width: Int` | The video width, in pixels. |
| `height: Int` | The video height, in pixels. |
| `frameRate: Double` | The video frame rate, in frames per second. |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `width` or `height` is not positive, or if `frameRate` is not positive and finite. |

### forLiveStreaming

```
java-static fun forLiveStreaming(
    width: Int,
    height: Int,
    frameRate: Double,
    targetMaxBitrate: Int
): VideoEncoderConstraints!
```

Returns constraints with presets for live streaming.

Uses `CBR rate control` with `B-frames allowed`.

| Parameters |
|---|---|
| `width: Int` | The video width, in pixels. |
| `height: Int` | The video height, in pixels. |
| `frameRate: Double` | The video frame rate, in frames per second. |
| `targetMaxBitrate: Int` | The target maximum bitrate, in bits per second (bps). |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `width`, `height`, or `targetMaxBitrate` is not positive, or if `frameRate` is not positive and finite. |

### forMessaging

```
java-static fun forMessaging(
    width: Int,
    height: Int,
    frameRate: Double,
    targetMaxBitrate: Int
): VideoEncoderConstraints!
```

Returns constraints with presets for messaging, where fitting within a strict file-size or bitrate limit is the top priority.

Uses `VBR rate control` with `B-frames allowed`.

| Parameters |
|---|---|
| `width: Int` | The video width, in pixels. |
| `height: Int` | The video height, in pixels. |
| `frameRate: Double` | The video frame rate, in frames per second. |
| `targetMaxBitrate: Int` | The target maximum bitrate, in bits per second (bps). |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `width`, `height`, or `targetMaxBitrate` is not positive, or if `frameRate` is not positive and finite. |

### forRealTimeCommunication

```
java-static fun forRealTimeCommunication(
    width: Int,
    height: Int,
    frameRate: Double,
    targetMaxBitrate: Int
): VideoEncoderConstraints!
```

Returns constraints with presets for real-time communication (such as video calling) optimized for minimal latency.

Uses `CBR rate control` with `B-frames disallowed`.

| Parameters |
|---|---|
| `width: Int` | The video width, in pixels. |
| `height: Int` | The video height, in pixels. |
| `frameRate: Double` | The video frame rate, in frames per second. |
| `targetMaxBitrate: Int` | The target maximum bitrate, in bits per second (bps). |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `width`, `height`, or `targetMaxBitrate` is not positive, or if `frameRate` is not positive and finite. |

### forSocialPosting

```
java-static fun forSocialPosting(width: Int, height: Int, frameRate: Double): VideoEncoderConstraints!
```

Returns constraints with presets for social media posting.

The target quality is `QUALITY_LEVEL_GOOD`. Uses ` VBR rate control` with ` B-frames allowed`. Currently uses the same presets as `forGalleryExport`, which is a separate use case so that its presets can diverge in the future.

| Parameters |
|---|---|
| `width: Int` | The video width, in pixels. |
| `height: Int` | The video height, in pixels. |
| `frameRate: Double` | The video frame rate, in frames per second. |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `width` or `height` is not positive, or if `frameRate` is not positive and finite. |