VideoEncoderConstraints.Builder


public final class VideoEncoderConstraints.Builder


Builder for VideoEncoderConstraints instances.

Summary

Public constructors

Builder(int width, int height, double frameRate)

Creates a new instance.

Public constructors

Builder

public Builder(int width, int height, double frameRate)

Creates a new instance.

Parameters
int width

The width in pixels.

int height

The height in pixels.

double frameRate

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 methods

build

public VideoEncoderConstraints build()

Builds a VideoEncoderConstraints instance.

setAllowedCodecs

@CanIgnoreReturnValue
public VideoEncoderConstraints.Builder setAllowedCodecs(@C.VideoCodecFlags int allowedCodecs)

Sets the allowed codecs.

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

setBFramesAllowed

@CanIgnoreReturnValue
public VideoEncoderConstraints.Builder setBFramesAllowed(boolean bFramesAllowed)

Sets whether B-frames are allowed.

The default is true.

setBitDepth

@CanIgnoreReturnValue
public VideoEncoderConstraints.Builder setBitDepth(int bitDepth)

Sets the bit depth.

The default is 8.

setKeyFrameIntervalSeconds

@CanIgnoreReturnValue
public VideoEncoderConstraints.Builder setKeyFrameIntervalSeconds(float keyFrameIntervalSeconds)

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
public VideoEncoderConstraints.Builder setMaxBitrate(int maxBitrate)

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
public VideoEncoderConstraints.Builder setResolution(int width, int height, double frameRate)

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
public VideoEncoderConstraints.Builder setTargetQuality(double targetQuality)

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.