DefaultEncoderFactory


@UnstableApi
class DefaultEncoderFactory : Codec.EncoderFactory


A default implementation of Codec.EncoderFactory.

Summary

Nested types

A builder for DefaultEncoderFactory instances.

Public functions

Boolean

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

DefaultEncoderFactory.Builder!

Returns a Builder initialized with the values of this instance.

DefaultCodec!
createForAudioEncoding(format: Format!, logSessionId: LogSessionId?)

Returns a Codec for audio encoding.

DefaultCodec!
createForVideoEncoding(format: Format!, logSessionId: LogSessionId?)

Returns a DefaultCodec for video encoding.

Boolean
isVideoFormatSupported(requestedFormat: Format!)

Returns whether the requested video Format is supported by the encoder factory.

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.

buildUpon

fun buildUpon(): DefaultEncoderFactory.Builder!

Returns a Builder initialized with the values of this instance.

createForAudioEncoding

fun createForAudioEncoding(format: Format!, logSessionId: LogSessionId?): DefaultCodec!

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.

logSessionId: LogSessionId?

The optional LogSessionId of the android.media.metrics.EditingSession.

Returns
DefaultCodec!

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!, logSessionId: LogSessionId?): DefaultCodec!

Returns a DefaultCodec for video encoding.

Use setRequestedVideoEncoderSettings with bitrate set to request for a specific encoding bitrate. Bitrate settings in Format are ignored when bitrate is set.

isVideoFormatSupported

fun isVideoFormatSupported(requestedFormat: Format!): Boolean

Returns whether the requested video Format is supported by the encoder factory.

This is an experimental API and is currently being used for FrameWriter specifically.

videoNeedsEncoding

fun videoNeedsEncoding(): Boolean

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