VideoEncoderConstraints.Builder


class VideoEncoderConstraints.Builder


Builder for VideoEncoderConstraints instances.

Summary

Public constructors

Builder(width: Int, height: Int, frameRate: Double)

Creates a new instance.

Public constructors

Builder

Builder(width: Int, height: Int, frameRate: Double)

Creates a new instance.

Parameters
width: Int

The width in pixels.

height: Int

The height in pixels.

frameRate: Double

The 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.

Public functions

build

fun build(): VideoEncoderConstraints!

Builds a VideoEncoderConstraints instance.

setAllowedCodecs

@CanIgnoreReturnValue
fun setAllowedCodecs(@C.VideoCodecFlags allowedCodecs: Int): VideoEncoderConstraints.Builder!

Sets the allowed codecs.

The default is C.VIDEO_CODEC_FLAG_H264 | C.VIDEO_CODEC_FLAG_H265 | C.VIDEO_CODEC_FLAG_AV1.

setBFramesAllowed

@CanIgnoreReturnValue
fun setBFramesAllowed(bFramesAllowed: Boolean): VideoEncoderConstraints.Builder!

Sets whether B-frames are allowed.

The default is true.

setBitDepth

@CanIgnoreReturnValue
fun setBitDepth(bitDepth: Int): VideoEncoderConstraints.Builder!

Sets the bit depth.

The default is 8.

setKeyFrameIntervalSeconds

@CanIgnoreReturnValue
fun setKeyFrameIntervalSeconds(keyFrameIntervalSeconds: Float): VideoEncoderConstraints.Builder!

Sets the key-frame interval, in seconds.

The default is one second.

Throws
java.lang.IllegalArgumentException

if keyFrameIntervalSeconds is not positive and finite.

setMaxBitrate

@CanIgnoreReturnValue
fun setMaxBitrate(maxBitrate: Int): VideoEncoderConstraints.Builder!

Sets the maximum bitrate, in bits per second, or NO_VALUE to clear it.

The default is NO_VALUE.

Throws
java.lang.IllegalArgumentException

if maxBitrate is not positive and is not NO_VALUE.

java.lang.IllegalStateException

if targetQuality is already set.

setResolution

@CanIgnoreReturnValue
fun setResolution(width: Int, height: Int, frameRate: Double): VideoEncoderConstraints.Builder!

Sets the width in pixels, height in pixels, and 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.

setTargetQuality

@CanIgnoreReturnValue
fun setTargetQuality(targetQuality: Double): VideoEncoderConstraints.Builder!

Sets the target quality, or NO_VALUE to clear it.

The default is QUALITY_LEVEL_NEAR_LOSSLESS when neither targetQuality nor maxBitrate is set.

Throws
java.lang.IllegalArgumentException

if targetQuality is not in (0, 100] and is not NO_VALUE.

java.lang.IllegalStateException

if maxBitrate is already set.