public final class

DefaultEncoderFactory.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.transformer.DefaultEncoderFactory.Builder

Overview

A builder for DefaultEncoderFactory instances.

Summary

Constructors
publicBuilder(Context context)

Creates a new DefaultEncoderFactory.Builder.

Methods
public DefaultEncoderFactorybuild()

Creates an instance of DefaultEncoderFactory, using defaults if values are unset.

public DefaultEncoderFactory.BuildersetCodecPriority(int codecPriority)

Sets the codec priority.

public DefaultEncoderFactory.BuildersetEnableFallback(boolean enableFallback)

Sets whether the encoder can fallback.

public DefaultEncoderFactory.BuildersetRequestedVideoEncoderSettings(VideoEncoderSettings requestedVideoEncoderSettings)

Sets the requested VideoEncoderSettings.

public DefaultEncoderFactory.BuildersetVideoEncoderSelector(EncoderSelector videoEncoderSelector)

Sets the video EncoderSelector.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(Context context)

Creates a new DefaultEncoderFactory.Builder.

Methods

public DefaultEncoderFactory.Builder setVideoEncoderSelector(EncoderSelector videoEncoderSelector)

Sets the video EncoderSelector.

The default value is EncoderSelector.DEFAULT.

public DefaultEncoderFactory.Builder setRequestedVideoEncoderSettings(VideoEncoderSettings requestedVideoEncoderSettings)

Sets the requested VideoEncoderSettings.

Values in requestedVideoEncoderSettings may be ignored to improve encoding quality and/or reduce failures.

VideoEncoderSettings.profile and VideoEncoderSettings.level are ignored for MimeTypes.VIDEO_H264. Consider implementing Codec.EncoderFactory if such adjustments are unwanted.

requestedVideoEncoderSettings should be handled with care because there is no fallback support for it. For example, using incompatible VideoEncoderSettings.profile and VideoEncoderSettings.level can cause codec configuration failure. Setting an unsupported VideoEncoderSettings.bitrateMode may cause encoder instantiation failure.

The default value is VideoEncoderSettings.DEFAULT.

public DefaultEncoderFactory.Builder setEnableFallback(boolean enableFallback)

Sets whether the encoder can fallback.

With format fallback enabled, when the requested Format is not supported, DefaultEncoderFactory finds a format that is supported by the device and configures the Codec with it. The fallback process may change the requested MIME type, resolution, bitrate, profile/level etc.

The default value is true.

public DefaultEncoderFactory.Builder setCodecPriority(int codecPriority)

Sets the codec priority.

Specifying codec priority allows the resource manager in the platform to reclaim less important codecs before more important codecs.

It is recommended to use predefined like C.PRIORITY_PROCESSING_FOREGROUND, C.PRIORITY_PROCESSING_BACKGROUND or priority values defined relative to those defaults.

This method is a no-op on API versions before 35.

The default value is C.PRIORITY_PROCESSING_FOREGROUND.

Parameters:

codecPriority: The for the codec. Should be at most C.PRIORITY_MAX.

public DefaultEncoderFactory build()

Creates an instance of DefaultEncoderFactory, using defaults if values are unset.