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.
-
-
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
setDebugViewProvider(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
setFrameProcessorFactory(FrameProcessor.Factory frameProcessorFactory)
Sets theFrameProcessor.Factory
for theFrameProcessor
to use when applying effects to the video frames.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
setMuxerFactory(Muxer.Factory muxerFactory)
Sets the factory for muxers that write the media container.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
setVideoEffects(List<Effect> effects)
Sets theEffect
instances to apply to each video frame.
-
-
-
Method Detail
-
setTransformationRequest
@CanIgnoreReturnValue 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.
-
setVideoEffects
@CanIgnoreReturnValue public Transformer.Builder setVideoEffects(List<Effect> effects)
Sets theEffect
instances to apply to each video frame.The
Effect
instances are applied before any scale, rotation, or resolution changes specified in theTransformationRequest
but after slow-motion flattening.The default
FrameProcessor
only supportsGlEffect
instances. To use other effects, callsetFrameProcessorFactory(FrameProcessor.Factory)
with a customFrameProcessor.Factory
.- Parameters:
effects
- TheEffect
instances to apply to each video frame.- Returns:
- This builder.
-
setRemoveAudio
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue @Deprecated public Transformer.Builder setFlattenForSlowMotion(boolean flattenForSlowMotion)
Deprecated.
-
setListener
@CanIgnoreReturnValue @Deprecated public Transformer.Builder setListener(Transformer.Listener listener)
Deprecated.
-
addListener
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue public Transformer.Builder removeAllListeners()
Removes all listeners.This is equivalent to
Transformer.removeAllListeners()
.- Returns:
- This builder.
-
setMediaSourceFactory
@CanIgnoreReturnValue 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.
-
setDecoderFactory
@CanIgnoreReturnValue public Transformer.Builder setDecoderFactory(Codec.DecoderFactory decoderFactory)
Sets theCodec.DecoderFactory
that will be used by the transformer.The default value is a
DefaultDecoderFactory
instance.- Parameters:
decoderFactory
- TheCodec.DecoderFactory
instance.- Returns:
- This builder.
-
setEncoderFactory
@CanIgnoreReturnValue public Transformer.Builder setEncoderFactory(Codec.EncoderFactory encoderFactory)
Sets theCodec.EncoderFactory
that will be used by the transformer.The default value is a
DefaultEncoderFactory
instance.- Parameters:
encoderFactory
- TheCodec.EncoderFactory
instance.- Returns:
- This builder.
-
setFrameProcessorFactory
@CanIgnoreReturnValue public Transformer.Builder setFrameProcessorFactory(FrameProcessor.Factory frameProcessorFactory)
Sets theFrameProcessor.Factory
for theFrameProcessor
to use when applying effects to the video frames.This factory will be used to create the
FrameProcessor
used for applying theEffect
instances passed tosetVideoEffects(List)
and any additionalGlMatrixTransformation
instances derived from theTransformationRequest
set usingsetTransformationRequest(TransformationRequest)
.The default is
GlEffectsFrameProcessor.Factory
.- Parameters:
frameProcessorFactory
- TheFrameProcessor.Factory
to use.- Returns:
- This builder.
-
setMuxerFactory
@CanIgnoreReturnValue public Transformer.Builder setMuxerFactory(Muxer.Factory muxerFactory)
Sets the factory for muxers that write the media container.The default value is a
DefaultMuxer.Factory
.- Parameters:
muxerFactory
- AMuxer.Factory
.- Returns:
- This builder.
-
setLooper
@CanIgnoreReturnValue 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.
-
setDebugViewProvider
@CanIgnoreReturnValue public Transformer.Builder setDebugViewProvider(DebugViewProvider debugViewProvider)
Sets a provider for views to show diagnostic information (if available) during transformation.This is intended for debugging. The default value is
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.
-
-