AvifWriter.Builder


public final class AvifWriter.Builder


Builder class for constructing a AvifWriter object from specified parameters.

Summary

Public constructors

Builder(
    @NonNull FileDescriptor fd,
    @IntRange(from = 1) int width,
    @IntRange(from = 1) int height,
    int inputMode
)

Construct a Builder with output specified by its file descriptor.

Builder(
    @NonNull String path,
    @IntRange(from = 1) int width,
    @IntRange(from = 1) int height,
    int inputMode
)

Construct a Builder with output specified by its path.

Public methods

@NonNull AvifWriter

Build a AvifWriter object.

@NonNull AvifWriter.Builder
setGridEnabled(boolean gridEnabled)

Set whether to enable grid option.

@NonNull AvifWriter.Builder

Provide a handler for the AvifWriter to use.

@NonNull AvifWriter.Builder
setHighBitDepthEnabled(boolean highBitDepthEnabled)

Provide a setting for the AvifWriter to use high bit-depth or not.

@NonNull AvifWriter.Builder
setMaxImages(@IntRange(from = 1) int maxImages)

Set the maximum number of images to write.

@NonNull AvifWriter.Builder
setPrimaryIndex(@IntRange(from = 0) int primaryIndex)

Set the primary image index.

@NonNull AvifWriter.Builder
setQuality(@IntRange(from = 0, to = 100) int quality)

Set the quality for encoding images.

@NonNull AvifWriter.Builder
setRotation(@IntRange(from = 0) int rotation)

Set the image rotation in degrees.

Public constructors

Builder

Added in 1.1.0-alpha03
public Builder(
    @NonNull FileDescriptor fd,
    @IntRange(from = 1) int width,
    @IntRange(from = 1) int height,
    int inputMode
)

Construct a Builder with output specified by its file descriptor.

Parameters
@NonNull FileDescriptor fd

File descriptor of the file to be written.

@IntRange(from = 1) int width

Width of the image in number of pixels.

@IntRange(from = 1) int height

Height of the image in number of pixels.

int inputMode

Input mode for this writer, must be one of INPUT_MODE_BUFFER, INPUT_MODE_SURFACE, or INPUT_MODE_BITMAP.

Builder

Added in 1.1.0-alpha03
public Builder(
    @NonNull String path,
    @IntRange(from = 1) int width,
    @IntRange(from = 1) int height,
    int inputMode
)

Construct a Builder with output specified by its path.

Parameters
@NonNull String path

Path of the file to be written.

@IntRange(from = 1) int width

Width of the image in number of pixels.

@IntRange(from = 1) int height

Height of the image in number of pixels.

int inputMode

Input mode for this writer, must be one of INPUT_MODE_BUFFER, INPUT_MODE_SURFACE, or INPUT_MODE_BITMAP.

Public methods

build

Added in 1.1.0-alpha03
public @NonNull AvifWriter build()

Build a AvifWriter object.

Returns
@NonNull AvifWriter

a AvifWriter object built according to the specifications.

Throws
java.io.IOException

if failed to create the writer, possibly due to failure to create android.media.MediaMuxer or android.media.MediaCodec.

setGridEnabled

Added in 1.1.0-alpha03
public @NonNull AvifWriter.Builder setGridEnabled(boolean gridEnabled)

Set whether to enable grid option.

Parameters
boolean gridEnabled

Whether to enable grid option. If enabled, the tile size will be automatically chosen. Default is to enable.

Returns
@NonNull AvifWriter.Builder

this Builder object.

setHandler

Added in 1.1.0-alpha03
public @NonNull AvifWriter.Builder setHandler(@Nullable Handler handler)

Provide a handler for the AvifWriter to use.

Parameters
@Nullable Handler handler

If not null, client will receive all callbacks on the handler's looper. Otherwise, client will receive callbacks on a looper created by the writer. Default is null.

Returns
@NonNull AvifWriter.Builder

this Builder object.

setHighBitDepthEnabled

Added in 1.1.0-alpha03
public @NonNull AvifWriter.Builder setHighBitDepthEnabled(boolean highBitDepthEnabled)

Provide a setting for the AvifWriter to use high bit-depth or not.

Parameters
boolean highBitDepthEnabled

Whether to enable high bit-depth mode. Default is false, if true, AvifWriter will encode with high bit-depth.

Returns
@NonNull AvifWriter.Builder

this Builder object.

setMaxImages

Added in 1.1.0-alpha03
public @NonNull AvifWriter.Builder setMaxImages(@IntRange(from = 1) int maxImages)

Set the maximum number of images to write.

Parameters
@IntRange(from = 1) int maxImages

Max number of images to write. Frames exceeding this number will not be written to file. The writing can be stopped earlier before this number of images are written by stop, except for the input mode of INPUT_MODE_SURFACE, where the EOS timestamp must be specified (via setInputEndOfStreamTimestamp and reached. Default is 1.

Returns
@NonNull AvifWriter.Builder

this Builder object.

setPrimaryIndex

Added in 1.1.0-alpha03
public @NonNull AvifWriter.Builder setPrimaryIndex(@IntRange(from = 0) int primaryIndex)

Set the primary image index.

Parameters
@IntRange(from = 0) int primaryIndex

Index of the image that should be marked as primary, must be within range [0, maxImages - 1] inclusive. Default is 0.

Returns
@NonNull AvifWriter.Builder

this Builder object.

setQuality

Added in 1.1.0-alpha03
public @NonNull AvifWriter.Builder setQuality(@IntRange(from = 0, to = 100) int quality)

Set the quality for encoding images.

Parameters
@IntRange(from = 0, to = 100) int quality

A number between 0 and 100 (inclusive), with 100 indicating the best quality supported by this implementation. Default is 100.

Returns
@NonNull AvifWriter.Builder

this Builder object.

setRotation

Added in 1.1.0-alpha03
public @NonNull AvifWriter.Builder setRotation(@IntRange(from = 0) int rotation)

Set the image rotation in degrees.

Parameters
@IntRange(from = 0) int rotation

Rotation angle in degrees (clockwise) of the image, must be 0, 90, 180 or 270. Default is 0.

Returns
@NonNull AvifWriter.Builder

this Builder object.