Class Transformer.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.Transformer.Builder
-
- Enclosing class:
- Transformer
public static final class Transformer.Builder extends Object
A builder forTransformer
instances.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Deprecated.UseBuilder(Context)
instead.Builder(Context context)
Creates a builder with default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Transformer.Builder
addListener(Transformer.Listener listener)
Adds aTransformer.Listener
to listen to the transformation events.Transformer
build()
Builds aTransformer
instance.Transformer.Builder
removeAllListeners()
Removes all listeners.Transformer.Builder
removeListener(Transformer.Listener listener)
Removes aTransformer.Listener
.Transformer.Builder
setContext(Context context)
Deprecated.UseBuilder(Context)
instead.Transformer.Builder
setDebugViewProvider(Transformer.DebugViewProvider debugViewProvider)
Sets a provider for views to show diagnostic information (if available) during transformation.Transformer.Builder
setDecoderFactory(Codec.DecoderFactory decoderFactory)
Sets theCodec.DecoderFactory
that will be used by the transformer.Transformer.Builder
setEncoderFactory(Codec.EncoderFactory encoderFactory)
Sets theCodec.EncoderFactory
that will be used by the transformer.Transformer.Builder
setFlattenForSlowMotion(boolean flattenForSlowMotion)
Deprecated.Transformer.Builder
setListener(Transformer.Listener listener)
Deprecated.Transformer.Builder
setLooper(Looper looper)
Sets theLooper
that must be used for all calls to the transformer and that is used to call listeners on.Transformer.Builder
setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)
Sets theMediaSource.Factory
to be used to retrieve the inputs to transform.Transformer.Builder
setOutputMimeType(String outputMimeType)
Deprecated.This feature will be removed in a following release and the MIME type of the output will always be MP4.Transformer.Builder
setRemoveAudio(boolean removeAudio)
Sets whether to remove the audio from the output.Transformer.Builder
setRemoveVideo(boolean removeVideo)
Sets whether to remove the video from the output.Transformer.Builder
setTransformationRequest(TransformationRequest transformationRequest)
Sets theTransformationRequest
which configures the editing and transcoding options.Transformer.Builder
setVideoFrameEffects(List<GlEffect> effects)
Sets the effects to apply to each video frame.
-
-
-
Constructor Detail
-
Builder
@Deprecated public Builder()
Deprecated.UseBuilder(Context)
instead.
-
-
Method Detail
-
setContext
@Deprecated public Transformer.Builder setContext(Context context)
Deprecated.UseBuilder(Context)
instead.
-
setTransformationRequest
public Transformer.Builder setTransformationRequest(TransformationRequest transformationRequest)
Sets theTransformationRequest
which configures the editing and transcoding options.Actual applied values may differ, per device capabilities.
Transformer.Listener.onFallbackApplied(MediaItem, TransformationRequest, TransformationRequest)
will be invoked with the actual applied values.- Parameters:
transformationRequest
- TheTransformationRequest
.- Returns:
- This builder.
-
setVideoFrameEffects
public Transformer.Builder setVideoFrameEffects(List<GlEffect> effects)
Sets the effects to apply to each video frame.The effects are applied before any scale, rotation, or resolution changes specified in the
TransformationRequest
but after slow-motion flattening.- Parameters:
effects
- The effects to apply to each video frame.- Returns:
- This builder.
-
setMediaSourceFactory
public Transformer.Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)
Sets theMediaSource.Factory
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
- AMediaSource.Factory
.- Returns:
- This builder.
-
setRemoveAudio
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.
-
setRemoveVideo
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.
-
setFlattenForSlowMotion
@Deprecated public Transformer.Builder setFlattenForSlowMotion(boolean flattenForSlowMotion)
Deprecated.
-
setOutputMimeType
@Deprecated public Transformer.Builder setOutputMimeType(String outputMimeType)
Deprecated.This feature will be removed in a following release and the MIME type of the output will always be MP4.
-
setListener
@Deprecated public Transformer.Builder setListener(Transformer.Listener listener)
Deprecated.
-
addListener
public Transformer.Builder addListener(Transformer.Listener listener)
Adds aTransformer.Listener
to listen to the transformation events.This is equivalent to
Transformer.addListener(Listener)
.- Parameters:
listener
- ATransformer.Listener
.- Returns:
- This builder.
-
removeListener
public Transformer.Builder removeListener(Transformer.Listener listener)
Removes aTransformer.Listener
.This is equivalent to
Transformer.removeListener(Listener)
.- Parameters:
listener
- ATransformer.Listener
.- Returns:
- This builder.
-
removeAllListeners
public Transformer.Builder removeAllListeners()
Removes all listeners.This is equivalent to
Transformer.removeAllListeners()
.- Returns:
- This builder.
-
setLooper
public Transformer.Builder setLooper(Looper looper)
Sets theLooper
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
- ALooper
.- Returns:
- This builder.
-
setEncoderFactory
public Transformer.Builder setEncoderFactory(Codec.EncoderFactory encoderFactory)
Sets theCodec.EncoderFactory
that will be used by the transformer.The default value is
Codec.EncoderFactory.DEFAULT
.- Parameters:
encoderFactory
- TheCodec.EncoderFactory
instance.- Returns:
- This builder.
-
setDecoderFactory
public Transformer.Builder setDecoderFactory(Codec.DecoderFactory decoderFactory)
Sets theCodec.DecoderFactory
that will be used by the transformer.The default value is
Codec.DecoderFactory.DEFAULT
.- Parameters:
decoderFactory
- TheCodec.DecoderFactory
instance.- Returns:
- This builder.
-
setDebugViewProvider
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.
-
build
public Transformer build()
Builds aTransformer
instance.- Throws:
NullPointerException
- If theContext
has not been provided.IllegalStateException
- If both audio and video have been removed (otherwise the output would not contain any samples).IllegalStateException
- If the muxer doesn't support the requested audio MIME type.IllegalStateException
- If the muxer doesn't support the requested video MIME type.
-
-