public interface

Codec.EncoderFactory

 androidx.media3.transformer.Codec.EncoderFactory

Subclasses:

DefaultEncoderFactory

Overview

A factory for encoder instances.

Summary

Methods
public booleanaudioNeedsEncoding()

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

public CodeccreateForAudioEncoding(Format format)

Returns a Codec for audio encoding.

public CodeccreateForVideoEncoding(Format format)

Returns a Codec for video encoding.

public booleanvideoNeedsEncoding()

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

Methods

public 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.

Format.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: The Format (of the output data) used to determine the underlying encoder and its configuration values. Format.sampleMimeType, Format.sampleRate, Format.channelCount and Format.bitrate are set to those of the desired output video format.

Returns:

A Codec for encoding audio to the requested MIME type.

public 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.

Format.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: The Format (of the output data) used to determine the underlying encoder and its configuration values. Format.sampleMimeType, Format.width and Format.height are set to those of the desired output video format. Format.frameRate is set to the requested output frame rate, if available. Format.colorInfo is set to the requested output color characteristics, if available. Format.rotationDegrees is 0 and Format.width >= Format.height, therefore the video is always in landscape orientation.

Returns:

A Codec for encoding video to the requested MIME type.

public boolean audioNeedsEncoding()

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

public boolean videoNeedsEncoding()

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