public final class

TransformationRequest.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.transformer.TransformationRequest.Builder

Overview

A builder for TransformationRequest instances.

Summary

Constructors
publicBuilder()

Creates a new instance with default values.

Methods
public TransformationRequestbuild()

Builds a TransformationRequest instance.

public TransformationRequest.Builderexperimental_setEnableHdrEditing(boolean enableHdrEditing)

Sets whether to attempt to process any input video stream as a high dynamic range (HDR) signal.

public TransformationRequest.BuildersetAudioMimeType(java.lang.String audioMimeType)

Sets the audio MIME type of the output.

public TransformationRequest.BuildersetFlattenForSlowMotion(boolean flattenForSlowMotion)

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

public TransformationRequest.BuildersetResolution(int outputHeight)

Sets the output resolution using the output height.

public TransformationRequest.BuildersetTransformationMatrix(Matrix transformationMatrix)

Sets the transformation matrix.

public TransformationRequest.BuildersetVideoMimeType(java.lang.String videoMimeType)

Sets the video MIME type of the output.

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

Constructors

public Builder()

Creates a new instance with default values.

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

Methods

public TransformationRequest.Builder setTransformationMatrix(Matrix transformationMatrix)

Sets the transformation matrix. The default value is to apply no change.

This can be used to perform operations supported by , like scaling and rotating the video.

The video dimensions will be on the x axis, from -aspectRatio to aspectRatio, and on the y axis, from -1 to 1.

For now, resolution will not be affected by this method.

Parameters:

transformationMatrix: The transformation to apply to video frames.

Returns:

This builder.

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 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.

Parameters:

flattenForSlowMotion: Whether to flatten for slow motion.

Returns:

This builder.

public TransformationRequest.Builder setResolution(int outputHeight)

Sets the output resolution using the output height. The default value C.LENGTH_UNSET corresponds to using the same height as the input. Output width will scale to preserve the input video's aspect ratio.

For now, only "popular" heights like 144, 240, 360, 480, 720, 1080, 1440, or 2160 are supported, to ensure compatibility on different devices.

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

Parameters:

outputHeight: The output height in pixels.

Returns:

This builder.

public TransformationRequest.Builder setVideoMimeType(java.lang.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:

Parameters:

videoMimeType: The MIME type of the video samples in the output.

Returns:

This builder.

public TransformationRequest.Builder setAudioMimeType(java.lang.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:

Parameters:

audioMimeType: The MIME type of the audio samples in the output.

Returns:

This builder.

public TransformationRequest.Builder experimental_setEnableHdrEditing(boolean enableHdrEditing)

Sets whether to attempt to process any input video stream as a high dynamic range (HDR) signal.

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 processing and encoding support.

Parameters:

enableHdrEditing: Whether to attempt to process any input video stream as a high dynamic range (HDR) signal.

Returns:

This builder.

public TransformationRequest build()

Builds a TransformationRequest instance.