Codec.EncoderFactory


interface Codec.EncoderFactory

Known direct subclasses
DefaultEncoderFactory

A default implementation of Codec.EncoderFactory.


A factory for encoder instances.

Summary

Public functions

Boolean

Returns whether the audio needs to be encoded because of encoder specific configuration.

Codec!

Returns a Codec for audio encoding.

Codec!

Returns a Codec for video encoding.

Boolean

Returns whether the video needs to be encoded because of encoder specific configuration.

Public functions

audioNeedsEncoding

fun audioNeedsEncoding(): Boolean

Returns whether the audio needs to be encoded because of encoder specific configuration.

createForAudioEncoding

fun createForAudioEncoding(format: Format!): Codec!

Returns a Codec for audio encoding.

The caller should ensure the MIME type is supported on the device before calling this method.

codecs contains the codec string for the original input media that has been decoded and processed. This is provided only as a hint, and the factory may encode to a different format.

Parameters
format: Format!

The Format (of the output data) used to determine the underlying encoder and its configuration values. sampleMimeType, sampleRate, channelCount and bitrate are set to those of the desired output video format.

Returns
Codec!

A Codec for encoding audio to the requested MIME type.

Throws
androidx.media3.transformer.ExportException

If no suitable Codec can be created.

createForVideoEncoding

fun createForVideoEncoding(format: Format!): Codec!

Returns a Codec for video encoding.

The caller should ensure the MIME type is supported on the device before calling this method. If encoding to HDR, the caller should also ensure the color characteristics are supported.

codecs contains the codec string for the original input media that has been decoded and processed. This is provided only as a hint, and the factory may encode to a different format.

Parameters
format: Format!

The Format (of the output data) used to determine the underlying encoder and its configuration values. sampleMimeType, width and height are set to those of the desired output video format. frameRate is set to the requested output frame rate, if available. colorInfo is set to the requested output color characteristics, if available. rotationDegrees is always 0.

Returns
Codec!

A Codec for encoding video to the requested MIME type.

Throws
androidx.media3.transformer.ExportException

If no suitable Codec can be created.

videoNeedsEncoding

fun videoNeedsEncoding(): Boolean

Returns whether the video needs to be encoded because of encoder specific configuration.