public final class

Transformer.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.transformer.Transformer.Builder

Overview

A builder for Transformer instances.

Summary

Constructors
publicBuilder()

publicBuilder(Context context)

Creates a builder with default values.

Methods
public Transformer.BuilderaddListener(Transformer.Listener listener)

Adds a Transformer.Listener to listen to the transformation events.

public Transformerbuild()

Builds a Transformer instance.

public Transformer.BuilderremoveAllListeners()

Removes all listeners.

public Transformer.BuilderremoveListener(Transformer.Listener listener)

Removes a Transformer.Listener.

public Transformer.BuildersetContext(Context context)

public Transformer.BuildersetDebugViewProvider(Transformer.DebugViewProvider debugViewProvider)

Sets a provider for views to show diagnostic information (if available) during transformation.

public Transformer.BuildersetEncoderFactory(Codec.EncoderFactory encoderFactory)

Sets the Codec.EncoderFactory that will be used by the transformer.

public Transformer.BuildersetFlattenForSlowMotion(boolean flattenForSlowMotion)

public Transformer.BuildersetListener(Transformer.Listener listener)

public Transformer.BuildersetLooper(Looper looper)

Sets the that must be used for all calls to the transformer and that is used to call listeners on.

public Transformer.BuildersetMediaSourceFactory(MediaSource.Factory mediaSourceFactory)

Sets the to be used to retrieve the inputs to transform.

public Transformer.BuildersetOutputMimeType(java.lang.String outputMimeType)

public Transformer.BuildersetRemoveAudio(boolean removeAudio)

Sets whether to remove the audio from the output.

public Transformer.BuildersetRemoveVideo(boolean removeVideo)

Sets whether to remove the video from the output.

public Transformer.BuildersetTransformationRequest(TransformationRequest transformationRequest)

Sets the TransformationRequest which configures the editing and transcoding options.

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

Constructors

public Builder()

Deprecated: Use Transformer.Builder instead.

public Builder(Context context)

Creates a builder with default values.

Parameters:

context: The .

Methods

public Transformer.Builder setContext(Context context)

Deprecated: Use Transformer.Builder instead.

public Transformer.Builder setTransformationRequest(TransformationRequest transformationRequest)

Sets the TransformationRequest which configures the editing and transcoding options.

Parameters:

transformationRequest: The TransformationRequest.

Returns:

This builder.

public Transformer.Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)

Sets the to be used to retrieve the inputs to transform. The default value is a DefaultMediaSourceFactory built with the context provided in the constructor.

Parameters:

mediaSourceFactory: A .

Returns:

This builder.

public Transformer.Builder setRemoveAudio(boolean removeAudio)

Sets whether to remove the audio from the output. The default value is false.

The audio and video cannot both be removed because the output would not contain any samples.

Parameters:

removeAudio: Whether to remove the audio.

Returns:

This builder.

public Transformer.Builder setRemoveVideo(boolean removeVideo)

Sets whether to remove the video from the output. The default value is false.

The audio and video cannot both be removed because the output would not contain any samples.

Parameters:

removeVideo: Whether to remove the video.

Returns:

This builder.

public Transformer.Builder setFlattenForSlowMotion(boolean flattenForSlowMotion)

Deprecated: Use TransformationRequest.Builder.setFlattenForSlowMotion(boolean) instead.

public Transformer.Builder setOutputMimeType(java.lang.String outputMimeType)

Deprecated: This feature will be removed in a following release and the MIME type of the output will always be MP4.

public Transformer.Builder setListener(Transformer.Listener listener)

Deprecated: Use Transformer.addListener(Transformer.Listener), Transformer.removeListener(Transformer.Listener) or Transformer.Builder.removeAllListeners() instead.

public Transformer.Builder addListener(Transformer.Listener listener)

Adds a Transformer.Listener to listen to the transformation events.

This is equivalent to Transformer.addListener(Transformer.Listener).

Parameters:

listener: A Transformer.Listener.

Returns:

This builder.

public Transformer.Builder removeListener(Transformer.Listener listener)

Removes a Transformer.Listener.

This is equivalent to Transformer.removeListener(Transformer.Listener).

Parameters:

listener: A Transformer.Listener.

Returns:

This builder.

public Transformer.Builder removeAllListeners()

Removes all listeners.

This is equivalent to Transformer.removeAllListeners().

Returns:

This builder.

public Transformer.Builder setLooper(Looper looper)

Sets the that must be used for all calls to the transformer and that is used to call listeners on. The default value is the Looper of the thread that this builder was created on, or if that thread does not have a Looper, the Looper of the application's main thread.

Parameters:

looper: A .

Returns:

This builder.

public Transformer.Builder setEncoderFactory(Codec.EncoderFactory encoderFactory)

Sets the Codec.EncoderFactory that will be used by the transformer. The default value is Codec.EncoderFactory.DEFAULT.

Parameters:

encoderFactory: The Codec.EncoderFactory instance.

Returns:

This builder.

public Transformer.Builder setDebugViewProvider(Transformer.DebugViewProvider debugViewProvider)

Sets a provider for views to show diagnostic information (if available) during transformation. This is intended for debugging. The default value is Transformer.DebugViewProvider.NONE, which doesn't show any debug info.

Not all transformations will result in debug views being populated.

Parameters:

debugViewProvider: Provider for debug views.

Returns:

This builder.

public Transformer build()

Builds a Transformer instance.