AvifWriter.Builder


class AvifWriter.Builder


Builder class for constructing a AvifWriter object from specified parameters.

Summary

Public constructors

Builder(
    fd: FileDescriptor,
    width: @IntRange(from = 1) Int,
    height: @IntRange(from = 1) Int,
    inputMode: Int
)

Construct a Builder with output specified by its file descriptor.

Builder(
    path: String,
    width: @IntRange(from = 1) Int,
    height: @IntRange(from = 1) Int,
    inputMode: Int
)

Construct a Builder with output specified by its path.

Public functions

AvifWriter

Build a AvifWriter object.

AvifWriter.Builder
setGridEnabled(gridEnabled: Boolean)

Set whether to enable grid option.

AvifWriter.Builder
setHandler(handler: Handler?)

Provide a handler for the AvifWriter to use.

AvifWriter.Builder
setHighBitDepthEnabled(highBitDepthEnabled: Boolean)

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

AvifWriter.Builder
setMaxImages(maxImages: @IntRange(from = 1) Int)

Set the maximum number of images to write.

AvifWriter.Builder
setPrimaryIndex(primaryIndex: @IntRange(from = 0) Int)

Set the primary image index.

AvifWriter.Builder
setQuality(quality: @IntRange(from = 0, to = 100) Int)

Set the quality for encoding images.

AvifWriter.Builder
setRotation(rotation: @IntRange(from = 0) Int)

Set the image rotation in degrees.

Public constructors

Builder

Added in 1.1.0-alpha02
Builder(
    fd: FileDescriptor,
    width: @IntRange(from = 1) Int,
    height: @IntRange(from = 1) Int,
    inputMode: Int
)

Construct a Builder with output specified by its file descriptor.

Parameters
fd: FileDescriptor

File descriptor of the file to be written.

width: @IntRange(from = 1) Int

Width of the image in number of pixels.

height: @IntRange(from = 1) Int

Height of the image in number of pixels.

inputMode: Int

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-alpha02
Builder(
    path: String,
    width: @IntRange(from = 1) Int,
    height: @IntRange(from = 1) Int,
    inputMode: Int
)

Construct a Builder with output specified by its path.

Parameters
path: String

Path of the file to be written.

width: @IntRange(from = 1) Int

Width of the image in number of pixels.

height: @IntRange(from = 1) Int

Height of the image in number of pixels.

inputMode: Int

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

Public functions

build

Added in 1.1.0-alpha02
fun build(): AvifWriter

Build a AvifWriter object.

Returns
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-alpha02
fun setGridEnabled(gridEnabled: Boolean): AvifWriter.Builder

Set whether to enable grid option.

Parameters
gridEnabled: Boolean

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

Returns
AvifWriter.Builder

this Builder object.

setHandler

Added in 1.1.0-alpha02
fun setHandler(handler: Handler?): AvifWriter.Builder

Provide a handler for the AvifWriter to use.

Parameters
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
AvifWriter.Builder

this Builder object.

setHighBitDepthEnabled

Added in 1.1.0-alpha02
fun setHighBitDepthEnabled(highBitDepthEnabled: Boolean): AvifWriter.Builder

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

Parameters
highBitDepthEnabled: Boolean

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

Returns
AvifWriter.Builder

this Builder object.

setMaxImages

Added in 1.1.0-alpha02
fun setMaxImages(maxImages: @IntRange(from = 1) Int): AvifWriter.Builder

Set the maximum number of images to write.

Parameters
maxImages: @IntRange(from = 1) Int

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
AvifWriter.Builder

this Builder object.

setPrimaryIndex

Added in 1.1.0-alpha02
fun setPrimaryIndex(primaryIndex: @IntRange(from = 0) Int): AvifWriter.Builder

Set the primary image index.

Parameters
primaryIndex: @IntRange(from = 0) Int

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

Returns
AvifWriter.Builder

this Builder object.

setQuality

Added in 1.1.0-alpha02
fun setQuality(quality: @IntRange(from = 0, to = 100) Int): AvifWriter.Builder

Set the quality for encoding images.

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

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

Returns
AvifWriter.Builder

this Builder object.

setRotation

Added in 1.1.0-alpha02
fun setRotation(rotation: @IntRange(from = 0) Int): AvifWriter.Builder

Set the image rotation in degrees.

Parameters
rotation: @IntRange(from = 0) Int

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

Returns
AvifWriter.Builder

this Builder object.