Package com.google.android.exoplayer2.transformer

## 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 for `Transformer` instances.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `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 a `Transformer.Listener` to listen to the transformation events.
    `Transformer` | `build()` | Builds a `Transformer` instance.
    `Transformer.Builder` | `removeAllListeners()` | Removes all listeners.
    `Transformer.Builder` | `removeListener​(Transformer.Listener listener)` | Removes a `Transformer.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 the `Codec.DecoderFactory` that will be used by the transformer.
    `Transformer.Builder` | `setEncoderFactory​(Codec.EncoderFactory encoderFactory)` | Sets the `Codec.EncoderFactory` that will be used by the transformer.
    `Transformer.Builder` | `setFlattenForSlowMotion​(boolean flattenForSlowMotion)` | Deprecated. Use `TransformationRequest.Builder.setFlattenForSlowMotion(boolean)` instead.
    `Transformer.Builder` | `setFrameProcessorFactory​(FrameProcessor.Factory frameProcessorFactory)` | Sets the `FrameProcessor.Factory` for the `FrameProcessor` to use when applying effects to the video frames.
    `Transformer.Builder` | `setListener​(Transformer.Listener listener)` | Deprecated. Use `addListener(Listener)`, `removeListener(Listener)` or `removeAllListeners()` instead.
    `Transformer.Builder` | `setLooper​(Looper looper)` | Sets the `Looper` 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 the `MediaSource.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 the `TransformationRequest` which configures the editing and transcoding options.
    `Transformer.Builder` | `setVideoEffects​(List<Effect> effects)` | Sets the `Effect` instances to apply to each video frame.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Builder

          public Builder​(Context context)

      Creates a builder with default values.
      Parameters:
        `context` - The `Context`.

  - ### Method Detail

    - #### setTransformationRequest

          @CanIgnoreReturnValue
          public Transformer.Builder setTransformationRequest​(TransformationRequest transformationRequest)

      Sets the `TransformationRequest` 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` - The `TransformationRequest`.
      Returns:
        This builder.

    - #### setVideoEffects

          @CanIgnoreReturnValue
          public Transformer.Builder setVideoEffects​(List<Effect> effects)

      Sets the `Effect` instances to apply to each video frame.

      The `Effect` instances are applied before any scale, rotation, or resolution changes specified in the `TransformationRequest` but after slow-motion flattening.

      The default `FrameProcessor` only supports `GlEffect` instances. To use other effects, call `setFrameProcessorFactory(FrameProcessor.Factory)` with a custom `FrameProcessor.Factory`.

      Parameters:
        `effects` - The `Effect` 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.
      Use `TransformationRequest.Builder.setFlattenForSlowMotion(boolean)` instead.

    - #### setListener

          @CanIgnoreReturnValue
          @Deprecated
          public Transformer.Builder setListener​(Transformer.Listener listener)

      Deprecated.
      Use `addListener(Listener)`, `removeListener(Listener)` or `removeAllListeners()` instead.

    - #### addListener

          @CanIgnoreReturnValue
          public Transformer.Builder addListener​(Transformer.Listener listener)

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

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

      Parameters:
        `listener` - A `Transformer.Listener`.
      Returns:
        This builder.

    - #### removeListener

          @CanIgnoreReturnValue
          public Transformer.Builder removeListener​(Transformer.Listener listener)

      Removes a `Transformer.Listener`.

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

      Parameters:
        `listener` - A `Transformer.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 the `MediaSource.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` - A `MediaSource.Factory`.
      Returns:
        This builder.

    - #### setDecoderFactory

          @CanIgnoreReturnValue
          public Transformer.Builder setDecoderFactory​(Codec.DecoderFactory decoderFactory)

      Sets the `Codec.DecoderFactory` that will be used by the transformer.

      The default value is a `DefaultDecoderFactory` instance.

      Parameters:
        `decoderFactory` - The `Codec.DecoderFactory` instance.
      Returns:
        This builder.

    - #### setEncoderFactory

          @CanIgnoreReturnValue
          public Transformer.Builder setEncoderFactory​(Codec.EncoderFactory encoderFactory)

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

      The default value is a `DefaultEncoderFactory` instance.

      Parameters:
        `encoderFactory` - The `Codec.EncoderFactory` instance.
      Returns:
        This builder.

    - #### setFrameProcessorFactory

          @CanIgnoreReturnValue
          public Transformer.Builder setFrameProcessorFactory​(FrameProcessor.Factory frameProcessorFactory)

      Sets the `FrameProcessor.Factory` for the `FrameProcessor` to use when applying effects to the video frames.

      This factory will be used to create the `FrameProcessor` used for applying the `Effect` instances passed to `setVideoEffects(List)` and any additional `GlMatrixTransformation` instances derived from the `TransformationRequest` set using `setTransformationRequest(TransformationRequest)`.

      The default is `GlEffectsFrameProcessor.Factory`.

      Parameters:
        `frameProcessorFactory` - The `FrameProcessor.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` - A `Muxer.Factory`.
      Returns:
        This builder.

    - #### setLooper

          @CanIgnoreReturnValue
          public Transformer.Builder setLooper​(Looper looper)

      Sets the `Looper` 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 `Looper`.
      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 a `Transformer` instance.
      Throws:
        `NullPointerException` - If the `Context` 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.