DefaultEncoderFactory

@UnstableApi
class DefaultEncoderFactory : Codec.EncoderFactory


A default implementation of Codec.EncoderFactory.

Summary

Nested types

A builder for DefaultEncoderFactory instances.

Public constructors

This function is deprecated.

Use Builder instead.

DefaultEncoderFactory(
    context: Context!,
    videoEncoderSelector: EncoderSelector!,
    enableFallback: Boolean
)

This function is deprecated.

Use Builder instead.

DefaultEncoderFactory(
    context: Context!,
    videoEncoderSelector: EncoderSelector!,
    requestedVideoEncoderSettings: VideoEncoderSettings!,
    enableFallback: Boolean
)

This function is deprecated.

Use Builder instead.

Public functions

DefaultCodec!

Returns a Codec for audio encoding.

DefaultCodec!

Returns a DefaultCodec for video encoding.

Boolean

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

Inherited functions

From androidx.media3.transformer.Codec.EncoderFactory
Boolean

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

Public constructors

DefaultEncoderFactory

DefaultEncoderFactory(context: Context!)

DefaultEncoderFactory

DefaultEncoderFactory(
    context: Context!,
    videoEncoderSelector: EncoderSelector!,
    enableFallback: Boolean
)

DefaultEncoderFactory

DefaultEncoderFactory(
    context: Context!,
    videoEncoderSelector: EncoderSelector!,
    requestedVideoEncoderSettings: VideoEncoderSettings!,
    enableFallback: Boolean
)

Public functions

createForAudioEncoding

fun createForAudioEncoding(format: Format!): 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.

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!): 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 or enableHighQualityTargeting is set.

videoNeedsEncoding

fun videoNeedsEncoding(): Boolean

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