Package com.google.android.exoplayer2.transformer

## Class TransformationRequest.Builder

- java.lang.Object
- - com.google.android.exoplayer2.transformer.TransformationRequest.Builder

- Enclosing class:
    TransformationRequest

      public static final class TransformationRequest.Builder
      extends Object

  A builder for `TransformationRequest` instances.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Builder()` | Creates a new instance with default values.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `TransformationRequest` | `build()` | Builds a `TransformationRequest` instance.
    `TransformationRequest.Builder` | `experimental_setEnableHdrEditing​(boolean enableHdrEditing)` | Sets whether to allow processing high dynamic range (HDR) input video streams as HDR.
    `TransformationRequest.Builder` | `experimental_setForceInterpretHdrVideoAsSdr​(boolean forceInterpretHdrVideoAsSdr)` | Sets whether to interpret HDR video as SDR, resulting in washed out video.
    `TransformationRequest.Builder` | `setAudioMimeType​(String audioMimeType)` | Sets the audio MIME type of the output.
    `TransformationRequest.Builder` | `setEnableRequestSdrToneMapping​(boolean enableRequestSdrToneMapping)` | Sets whether to request tone-mapping to standard dynamic range (SDR).
    `TransformationRequest.Builder` | `setFlattenForSlowMotion​(boolean flattenForSlowMotion)` | Sets whether the input should be flattened for media containing slow motion markers.
    `TransformationRequest.Builder` | `setResolution​(int outputHeight)` | Sets the output resolution using the output height.
    `TransformationRequest.Builder` | `setRotationDegrees​(float rotationDegrees)` | Sets the rotation, in degrees, counterclockwise, to apply to each frame.
    `TransformationRequest.Builder` | `setScale​(float scaleX, float scaleY)` | Sets the x and y axis scaling factors to apply to each frame's width and height, stretching the video along these axes appropriately.
    `TransformationRequest.Builder` | `setVideoMimeType​(String videoMimeType)` | Sets the video MIME type of the output.

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

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

- - ### Constructor Detail

    - #### Builder

          public Builder()

      Creates a new instance with default values.

      Use `TransformationRequest.buildUpon()` to obtain a builder representing an existing `TransformationRequest`.

  - ### Method Detail

    - #### setFlattenForSlowMotion

          @CanIgnoreReturnValue
          public TransformationRequest.Builder setFlattenForSlowMotion​(boolean flattenForSlowMotion)

      Sets whether the input should be flattened for media containing slow motion markers.

      The transformed output is obtained by removing the slow motion metadata and by actually slowing down the parts of the video and audio streams defined in this metadata. The default value for `flattenForSlowMotion` is `false`.

      Only Samsung Extension Format (SEF) slow motion metadata type is supported. The transformation has no effect if the input does not contain this metadata type.

      For SEF slow motion media, the following assumptions are made on the input:

      - The input container format is (unfragmented) MP4.
      - The input contains an AVC video elementary stream with temporal SVC.
      - The recording frame rate of the video is 120 or 240 fps.

      If specifying a `MediaSource.Factory` using `Transformer.Builder.setMediaSourceFactory(MediaSource.Factory)`, make sure that `Mp4Extractor.FLAG_READ_SEF_DATA` is set on the `Mp4Extractor` used. Otherwise, the slow motion metadata will be ignored and the input won't be flattened.

      Using slow motion flattening together with `MediaItem.ClippingConfiguration` is not supported yet.

      Parameters:
        `flattenForSlowMotion` - Whether to flatten for slow motion.
      Returns:
        This builder.

    - #### setScale

          @CanIgnoreReturnValue
          public TransformationRequest.Builder setScale​(float scaleX,
                                                        float scaleY)

      Sets the x and y axis scaling factors to apply to each frame's width and height, stretching the video along these axes appropriately.

      The default value for `scaleX` and `scaleY`, 1, corresponds to not scaling along the x and y axes, respectively.

      Parameters:
        `scaleX` - The multiplier by which the frame will scale horizontally, along the x-axis.
        `scaleY` - The multiplier by which the frame will scale vertically, along the y-axis.
      Returns:
        This builder.

    - #### setRotationDegrees

          @CanIgnoreReturnValue
          public TransformationRequest.Builder setRotationDegrees​(float rotationDegrees)

      Sets the rotation, in degrees, counterclockwise, to apply to each frame.

      The output frame's width and height are automatically adjusted to preserve all input pixels. The rotated input frame is fitted inside an enclosing black rectangle if its edges aren't parallel to the x and y axes.

      The default value, 0, corresponds to not applying any rotation.

      Parameters:
        `rotationDegrees` - The counterclockwise rotation, in degrees.
      Returns:
        This builder.

    - #### setResolution

          @CanIgnoreReturnValue
          public TransformationRequest.Builder setResolution​(int outputHeight)

      Sets the output resolution using the output height.

      Output width of the displayed video will scale to preserve the video's aspect ratio after other transformations.

      For example, a 1920x1440 video can be scaled to 640x480 by calling setResolution(480).

      The default value, `C.LENGTH_UNSET`, leaves the width and height unchanged unless scaling or @linkplain #setRotationDegrees(float) rotation} are requested.

      Parameters:
        `outputHeight` - The output height of the displayed video, in pixels.
      Returns:
        This builder.

    - #### setVideoMimeType

          @CanIgnoreReturnValue
          public TransformationRequest.Builder setVideoMimeType​(@Nullable
                                                                String videoMimeType)

      Sets the video MIME type of the output.

      The default value is `null` which corresponds to using the same MIME type as the input. Supported MIME types are:

      - `MimeTypes.VIDEO_H263`
      - `MimeTypes.VIDEO_H264`
      - `MimeTypes.VIDEO_H265` from API level 24
      - `MimeTypes.VIDEO_MP4V`
      Parameters:
        `videoMimeType` - The MIME type of the video samples in the output.
      Returns:
        This builder.
      Throws:
        `IllegalArgumentException` - If the `videoMimeType` is non-null but not a video MIME type.

    - #### setAudioMimeType

          @CanIgnoreReturnValue
          public TransformationRequest.Builder setAudioMimeType​(@Nullable
                                                                String audioMimeType)

      Sets the audio MIME type of the output.

      The default value is `null` which corresponds to using the same MIME type as the input. Supported MIME types are:

      - `MimeTypes.AUDIO_AAC`
      - `MimeTypes.AUDIO_AMR_NB`
      - `MimeTypes.AUDIO_AMR_WB`
      Parameters:
        `audioMimeType` - The MIME type of the audio samples in the output.
      Returns:
        This builder.
      Throws:
        `IllegalArgumentException` - If the `audioMimeType` is non-null but not an audio MIME type.

    - #### setEnableRequestSdrToneMapping

          @CanIgnoreReturnValue
          public TransformationRequest.Builder setEnableRequestSdrToneMapping​(boolean enableRequestSdrToneMapping)

      Sets whether to request tone-mapping to standard dynamic range (SDR). If enabled and supported, high dynamic range (HDR) input will be tone-mapped into an SDR opto-electrical transfer function before processing.

      The default value is `true`, which corresponds to tone-mapping output if possible.

      The setting has no effect if the input is already in SDR, or if tone-mapping is not supported. Currently tone-mapping is only guaranteed to be supported from Android T onwards.

      Setting this as `true` will set experimental_setEnableHdrEditing(boolean) and forceInterpretHdrVideoAsSdr to `false`.

      Parameters:
        `enableRequestSdrToneMapping` - Whether to request tone-mapping down to SDR.
      Returns:
        This builder.

    - #### experimental_setForceInterpretHdrVideoAsSdr

          @CanIgnoreReturnValue
          public TransformationRequest.Builder experimental_setForceInterpretHdrVideoAsSdr​(boolean forceInterpretHdrVideoAsSdr)

      Sets whether to interpret HDR video as SDR, resulting in washed out video.

      The default value is `false`, with `setEnableRequestSdrToneMapping(boolean)` being applied.

      Use of this flag may result in `TransformationException.ERROR_CODE_HDR_DECODING_UNSUPPORTED` or `ERROR_CODE_DECODING_FORMAT_UNSUPPORTED`.

      This method is experimental, and will be renamed or removed in a future release.

      If enabled, HDR information will be interpreted as SDR, which is much more widely supported than tone mapping or HDR editing. However, as HDR transfer functions and metadata will be ignored, contents will be displayed incorrectly, likely with a washed out look.

      The setting has no effect if the input is already in SDR.

      Setting this as `true` will set experimental_setEnableHdrEditing(boolean) and forceInterpretHdrVideoAsSdr to `false`.

      Parameters:
        `forceInterpretHdrVideoAsSdr` - Whether to interpret HDR contents as SDR.
      Returns:
        This builder.

    - #### experimental_setEnableHdrEditing

          @CanIgnoreReturnValue
          public TransformationRequest.Builder experimental_setEnableHdrEditing​(boolean enableHdrEditing)

      Sets whether to allow processing high dynamic range (HDR) input video streams as HDR.

      The default value is `false`, with `setEnableRequestSdrToneMapping(boolean)` being applied.

      This method is experimental, and will be renamed or removed in a future release. The HDR editing feature is under development and is intended for developing/testing HDR support.

      Setting this as `true` will set experimental_setEnableHdrEditing(boolean) and forceInterpretHdrVideoAsSdr to `false`.

      With this flag enabled, HDR streams will correctly edit in HDR, convert via tone-mapping to SDR, or throw an error, based on the device's HDR support. SDR streams will be interpreted the same way regardless of this flag's state.

      Parameters:
        `enableHdrEditing` - Whether to attempt to process any input video stream as a high dynamic range (HDR) signal.
      Returns:
        This builder.

    - #### build

          public TransformationRequest build()

      Builds a `TransformationRequest` instance.