Codec.EncoderFactory


public interface Codec.EncoderFactory

Known direct subclasses
DefaultEncoderFactory

A default implementation of Codec.EncoderFactory.


A factory for encoder instances.

Summary

Public methods

default boolean

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

abstract Codec

Returns a Codec for audio encoding.

abstract Codec

Returns a Codec for video encoding.

default boolean

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

Public methods

audioNeedsEncoding

default boolean audioNeedsEncoding()

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

createForAudioEncoding

abstract Codec createForAudioEncoding(Format format)

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

abstract Codec createForVideoEncoding(Format format)

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

default boolean videoNeedsEncoding()

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