# Transformer.Builder

Artifact: [androidx.media3:media3-transformer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/transformer/Transformer.java+class:androidx.media3.transformer.Transformer.Builder)

*** ** * ** ***


```
public final class Transformer.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/media3/transformer/Transformer` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#Builder(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Creates a builder with default values. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#addListener(androidx.media3.transformer.Transformer.Listener)(https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener listener)` Adds a `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener` to listen to the export events. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer` | `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#build()()` Builds a `https://developer.android.com/reference/androidx/media3/transformer/Transformer` instance. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#experimentalSetMaxFramesInEncoder(int)(int maxFramesInEncoder)` Limits how many video frames can be processed at any time by the `https://developer.android.com/reference/androidx/media3/transformer/Codec`. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#experimentalSetMp4EditListTrimEnabled(boolean)(boolean enabled)` Sets whether to use an MP4 edit list for trimming, to instruct players to ignore frames between the key frame before the trim start point, and the trim start point. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#experimentalSetTrimOptimizationEnabled(boolean)(boolean enabled)` Sets whether to attempt to optimize trims from the start of the `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` by transcoding as little of the file as possible and transmuxing the rest. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#removeAllListeners()()` Removes all `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener`. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#removeListener(androidx.media3.transformer.Transformer.Listener)(https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener listener)` Removes a `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener`. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setAssetLoaderFactory(androidx.media3.transformer.AssetLoader.Factory)(https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Factory assetLoaderFactory)` Sets the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Factory` to be used to retrieve the samples to export. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setAudioMimeType(java.lang.String)(https://developer.android.com/reference/java/lang/String.html audioMimeType)` Sets the audio `https://developer.android.com/reference/androidx/media3/common/MimeTypes` of the output. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setAudioMixerFactory(androidx.media3.transformer.AudioMixer.Factory)(https://developer.android.com/reference/androidx/media3/transformer/AudioMixer.Factory audioMixerFactory)` Sets the `https://developer.android.com/reference/androidx/media3/transformer/AudioMixer.Factory` to be used when `https://developer.android.com/reference/androidx/media3/transformer/AudioMixer` is needed. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/annotation/VisibleForTesting https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setClock(androidx.media3.common.util.Clock)(https://developer.android.com/reference/androidx/media3/common/util/Clock clock)` Sets the `https://developer.android.com/reference/androidx/media3/common/util/Clock` that will be used by the transformer. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setDebugViewProvider(androidx.media3.common.DebugViewProvider)(https://developer.android.com/reference/androidx/media3/common/DebugViewProvider debugViewProvider)` Sets a provider for views to show diagnostic information (if available) during export. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setEncoderFactory(androidx.media3.transformer.Codec.EncoderFactory)(https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory encoderFactory)` Sets the `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory` that will be used by the transformer. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setEnsureFileStartsOnVideoFrameEnabled(boolean)(boolean enabled)` Sets whether to ensure that the output file starts on a video frame. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setFrameProcessorFactory(androidx.media3.common.video.FrameProcessor.Factory)(https://developer.android.com/reference/androidx/media3/common/video/FrameProcessor.Factory frameProcessorFactory)` Sets the `https://developer.android.com/reference/androidx/media3/common/video/FrameProcessor.Factory` to be used to create `https://developer.android.com/reference/androidx/media3/common/video/FrameProcessor` instances. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setLooper(android.os.Looper)(https://developer.android.com/reference/android/os/Looper.html looper)` Sets the `https://developer.android.com/reference/android/os/Looper.html` that must be used for all calls to the transformer and that is used to call listeners on. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setMaxDelayBetweenMuxerSamplesMs(long)(long maxDelayBetweenMuxerSamplesMs)` Sets the maximum delay allowed between output samples regardless of the track type, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if there is no maximum. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setMuxerFactory(androidx.media3.muxer.Muxer.Factory)(https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory muxerFactory)` Sets the `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory` for muxers that write the media container. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setNativeHardwareBufferHelpers(androidx.media3.effect.HardwareBufferJniWrapper)( https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper hardwareBufferJniWrapper )` Sets the `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper` used to provide native helpers. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setPortraitEncodingEnabled(boolean)(boolean enabled)` Sets whether to encode portrait videos in portrait orientation. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setUsePlatformDiagnostics(boolean)(boolean usePlatformDiagnostics)` Sets whether transformer reports diagnostics data to the Android platform. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setVideoFrameProcessorFactory(androidx.media3.common.VideoFrameProcessor.Factory)( https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.Factory videoFrameProcessorFactory )` Sets the `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.Factory` to be used to create `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor` instances. |
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setVideoMimeType(java.lang.String)(https://developer.android.com/reference/java/lang/String.html videoMimeType)` Sets the video `https://developer.android.com/reference/androidx/media3/common/MimeTypes` of the output. |

## Public constructors

### Builder

```
public Builder(Context context)
```

Creates a builder with default values.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |

## Public methods

### addListener

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

Adds a `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener` to listen to the export events.

This is equivalent to `https://developer.android.com/reference/androidx/media3/transformer/Transformer#addListener(androidx.media3.transformer.Transformer.Listener)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener listener` | A `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### build

```
public Transformer build()
```

Builds a `https://developer.android.com/reference/androidx/media3/transformer/Transformer` instance.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If both audio and video have been removed (otherwise the output would not contain any samples). |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the muxer doesn't support the requested audio/video MIME type. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#experimentalSetMp4EditListTrimEnabled(boolean)` is enabled but the `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory` does not support writing negative timestamps to an edit list. |

### experimentalSetMaxFramesInEncoder

```
@CanIgnoreReturnValue
@ExperimentalApi
public Transformer.Builder experimentalSetMaxFramesInEncoder(int maxFramesInEncoder)
```

Limits how many video frames can be processed at any time by the `https://developer.android.com/reference/androidx/media3/transformer/Codec`.

A video frame starts encoding when it enters the `https://developer.android.com/reference/androidx/media3/transformer/Codec#getInputSurface()`, and finishes encoding when the corresponding `https://developer.android.com/reference/androidx/media3/transformer/Codec#releaseOutputBuffer(boolean)`.

The default value is `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`, which means no limit is enforced.

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

| Parameters |
|---|---|
| `int maxFramesInEncoder` | The maximum number of frames that the video encoder is allowed to process at a time, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if no limit is enforced. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `maxFramesInEncoder` is not equal to `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` and is non-positive. |

### experimentalSetMp4EditListTrimEnabled

```
@CanIgnoreReturnValue
@ExperimentalApi
public Transformer.Builder experimentalSetMp4EditListTrimEnabled(boolean enabled)
```

Sets whether to use an MP4 edit list for trimming, to instruct players to ignore frames between the key frame before the trim start point, and the trim start point.

This optimization has the following limitations, and will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html` if they are not met:

- Transformer has to transcode for any reason while trimming (such as if any video effects, apart from 90, 180 and 270 degree rotations are applied while trimming).
- Transformer is configured with any `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory` where `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory#supportsWritingNegativeTimestampsInEditList()` is false. The `https://developer.android.com/reference/androidx/media3/transformer/DefaultMuxer.Factory` supports this.

This optimization will be ignored in the following cases:

- Transformer input contains multiple assets (i.e. there is more than one `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` in the `https://developer.android.com/reference/androidx/media3/transformer/Composition`).
- Transformer input contains a single `https://developer.android.com/reference/androidx/media3/common/MediaItem` but the `https://developer.android.com/reference/androidx/media3/common/MediaItem#clippingConfiguration()` is not set.

If players do not respect the edit list the output file will be played from the key frame before the trim start point rather than the requested trim start point.

| Parameters |
|---|---|
| `boolean enabled` | Whether to enable mp4 edit list trimming. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### experimentalSetTrimOptimizationEnabled

```
@CanIgnoreReturnValue
@ExperimentalApi
public Transformer.Builder experimentalSetTrimOptimizationEnabled(boolean enabled)
```

Sets whether to attempt to optimize trims from the start of the `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` by transcoding as little of the file as possible and transmuxing the rest.

This optimization has the following limitations:

- Only supported for single-asset (i.e. only one `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItem` in the whole `https://developer.android.com/reference/androidx/media3/transformer/Composition`) exports of mp4 files.
- Not guaranteed to work with any effects.

This process relies on the given `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setEncoderFactory(androidx.media3.transformer.Codec.EncoderFactory)` providing the right encoder level and profiles when transcoding, so that the transcoded and transmuxed segments of the file can be stitched together. If the file segments can't be stitched together, Transformer throw away any progress and proceed with unoptimized export instead.

The `https://developer.android.com/reference/androidx/media3/transformer/ExportResult#optimizationResult()` will indicate whether the optimization was applied.

| Parameters |
|---|---|
| `boolean enabled` | Whether to enable trim optimization. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### removeAllListeners

```
@CanIgnoreReturnValue
public Transformer.Builder removeAllListeners()
```

Removes all `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener`.

This is equivalent to `https://developer.android.com/reference/androidx/media3/transformer/Transformer#removeAllListeners()`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### removeListener

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

Removes a `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener`.

This is equivalent to `https://developer.android.com/reference/androidx/media3/transformer/Transformer#removeListener(androidx.media3.transformer.Transformer.Listener)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener listener` | A `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setAssetLoaderFactory

```
@CanIgnoreReturnValue
public Transformer.Builder setAssetLoaderFactory(AssetLoader.Factory assetLoaderFactory)
```

Sets the `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Factory` to be used to retrieve the samples to export.

The default value is a `https://developer.android.com/reference/androidx/media3/transformer/DefaultAssetLoaderFactory` built with a `https://developer.android.com/reference/androidx/media3/exoplayer/source/DefaultMediaSourceFactory` and a `https://developer.android.com/reference/androidx/media3/transformer/DefaultDecoderFactory`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Factory assetLoaderFactory` | An `https://developer.android.com/reference/androidx/media3/transformer/AssetLoader.Factory`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setAudioMimeType

```
@CanIgnoreReturnValue
public Transformer.Builder setAudioMimeType(String audioMimeType)
```

Sets the audio `https://developer.android.com/reference/androidx/media3/common/MimeTypes` of the output.

If no audio MIME type is passed, the output audio MIME type is the same as the first `https://developer.android.com/reference/androidx/media3/common/MediaItem` in the `https://developer.android.com/reference/androidx/media3/transformer/Composition`.

Supported MIME types are:

- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#AUDIO_AAC()`
- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#AUDIO_AMR_NB()`
- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#AUDIO_AMR_WB()`
- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#AUDIO_RAW()`

If the MIME type is not supported, `https://developer.android.com/reference/androidx/media3/transformer/Transformer` will fallback to a supported MIME type and `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener#onFallbackApplied(androidx.media3.transformer.Composition,androidx.media3.transformer.TransformationRequest,androidx.media3.transformer.TransformationRequest)` will be invoked with the fallback value.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html audioMimeType` | The MIME type of the audio samples in the output. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the audio MIME type passed is not an audio `https://developer.android.com/reference/androidx/media3/common/MimeTypes`. |

### setAudioMixerFactory

```
@CanIgnoreReturnValue
public Transformer.Builder setAudioMixerFactory(AudioMixer.Factory audioMixerFactory)
```

Sets the `https://developer.android.com/reference/androidx/media3/transformer/AudioMixer.Factory` to be used when `https://developer.android.com/reference/androidx/media3/transformer/AudioMixer` is needed.

The default value is a `https://developer.android.com/reference/androidx/media3/transformer/DefaultAudioMixer.Factory` with default values.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/AudioMixer.Factory audioMixerFactory` | A `https://developer.android.com/reference/androidx/media3/transformer/AudioMixer.Factory`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setClock

```
@CanIgnoreReturnValue
@VisibleForTesting
public Transformer.Builder setClock(Clock clock)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/util/Clock` that will be used by the transformer.

The default value is `https://developer.android.com/reference/androidx/media3/common/util/Clock#DEFAULT()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/Clock clock` | The `https://developer.android.com/reference/androidx/media3/common/util/Clock` instance. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setDebugViewProvider

```
@CanIgnoreReturnValue
public Transformer.Builder setDebugViewProvider(DebugViewProvider debugViewProvider)
```

Sets a provider for views to show diagnostic information (if available) during export.

This is intended for debugging. The default value is `https://developer.android.com/reference/androidx/media3/common/DebugViewProvider#NONE()`, which doesn't show any debug info.

Not all exports will result in debug views being populated.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/DebugViewProvider debugViewProvider` | Provider for debug views. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setEncoderFactory

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

Sets the `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory` that will be used by the transformer.

The default value is a `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory` instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory encoderFactory` | The `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory` instance. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setEnsureFileStartsOnVideoFrameEnabled

```
@CanIgnoreReturnValue
public Transformer.Builder setEnsureFileStartsOnVideoFrameEnabled(boolean enabled)
```

Sets whether to ensure that the output file starts on a video frame.

Any audio samples that are earlier than the first video frame will be dropped. This can make the output of trimming operations more compatible with player implementations that don't show the first video frame until its presentation timestamp.

Ignored when `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#experimentalSetTrimOptimizationEnabled(boolean)` or `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#experimentalSetMp4EditListTrimEnabled(boolean)` is set.

| Parameters |
|---|---|
| `boolean enabled` | Whether to ensure that the file starts on a video frame. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setFrameProcessorFactory

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

Sets the `https://developer.android.com/reference/androidx/media3/common/video/FrameProcessor.Factory` to be used to create `https://developer.android.com/reference/androidx/media3/common/video/FrameProcessor` instances.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/video/FrameProcessor.Factory frameProcessorFactory` | The `https://developer.android.com/reference/androidx/media3/common/video/FrameProcessor.Factory`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setLooper

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

Sets the `https://developer.android.com/reference/android/os/Looper.html` 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 |
|---|---|
| `https://developer.android.com/reference/android/os/Looper.html looper` | A `https://developer.android.com/reference/android/os/Looper.html`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setMaxDelayBetweenMuxerSamplesMs

```
@CanIgnoreReturnValue
public Transformer.Builder setMaxDelayBetweenMuxerSamplesMs(long maxDelayBetweenMuxerSamplesMs)
```

Sets the maximum delay allowed between output samples regardless of the track type, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if there is no maximum. The default value is `https://developer.android.com/reference/androidx/media3/transformer/Transformer#DEFAULT_MAX_DELAY_BETWEEN_MUXER_SAMPLES_MS()`.

The export will be aborted when no sample is written in `
maxDelayBetweenMuxerSamplesMs`. Note that there is no guarantee that the export will be aborted exactly at that time.

| Parameters |
|---|---|
| `long maxDelayBetweenMuxerSamplesMs` | The maximum delay allowed (in microseconds). |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setMuxerFactory

```
@CanIgnoreReturnValue
public Transformer.Builder setMuxerFactory(Muxer.Factory muxerFactory)
```

Sets the `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory` for muxers that write the media container.

The default value is a `https://developer.android.com/reference/androidx/media3/transformer/DefaultMuxer.Factory`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory muxerFactory` | A `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setNativeHardwareBufferHelpers

```
@CanIgnoreReturnValue
@ExperimentalApi
public Transformer.Builder setNativeHardwareBufferHelpers(
    HardwareBufferJniWrapper hardwareBufferJniWrapper
)
```

Sets the `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper` used to provide native helpers.

The default value is `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJni#INSTANCE()`.

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

This will only be used if `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder#setFrameProcessorFactory(androidx.media3.common.video.FrameProcessor.Factory)` is set.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper hardwareBufferJniWrapper` | The `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper` to provide native helpers. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setPortraitEncodingEnabled

```
@CanIgnoreReturnValue
public Transformer.Builder setPortraitEncodingEnabled(boolean enabled)
```

Sets whether to encode portrait videos in portrait orientation.

The default value is `false`. In this case, portrait videos will be rotated by 90 degrees before being encoded, and metadata will be added to the output file to indicate that the video should be rotated back when played. This is done because encoding landscape videos is more largely supported. Enabling portrait encoding should therefore be done carefully because it is likely to result in more failures.

| Parameters |
|---|---|
| `boolean enabled` | Whether to encode portrait videos in portrait orientation. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setUsePlatformDiagnostics

```
@CanIgnoreReturnValue
public Transformer.Builder setUsePlatformDiagnostics(boolean usePlatformDiagnostics)
```

Sets whether transformer reports diagnostics data to the Android platform.

If enabled, transformer will use the `https://developer.android.com/reference/android/media/metrics/MediaMetricsManager.html` to create an `https://developer.android.com/reference/android/media/metrics/EditingSession.html` and forward editing events and performance data to this session. This helps to provide system performance and debugging information for media editing on this device. This data may also be collected by Google [if sharing usage and diagnostics data is enabled](https://support.google.com/accounts/answer/6078260) by the user of the device.

The default value is `true`.

| Parameters |
|---|---|
| `boolean usePlatformDiagnostics` | Whether transformer reports diagnostics data to the Android platform. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setVideoFrameProcessorFactory

```
@CanIgnoreReturnValue
public Transformer.Builder setVideoFrameProcessorFactory(
    VideoFrameProcessor.Factory videoFrameProcessorFactory
)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.Factory` to be used to create `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor` instances.

The default value is a `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoFrameProcessor.Factory` built with default values.

If passing in a `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoFrameProcessor.Factory`, the caller must not `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoFrameProcessor.Factory.Builder#setTextureOutput(androidx.media3.effect.GlTextureProducer.Listener,int)`.

If exporting a `https://developer.android.com/reference/androidx/media3/transformer/Composition` with multiple video `https://developer.android.com/reference/androidx/media3/transformer/EditedMediaItemSequence`, the `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.Factory` must be a `https://developer.android.com/reference/androidx/media3/effect/DefaultVideoFrameProcessor.Factory`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.Factory videoFrameProcessorFactory` | A `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.Factory`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

### setVideoMimeType

```
@CanIgnoreReturnValue
public Transformer.Builder setVideoMimeType(String videoMimeType)
```

Sets the video `https://developer.android.com/reference/androidx/media3/common/MimeTypes` of the output.

If no video MIME type is passed, the output video MIME type is the same as the first `https://developer.android.com/reference/androidx/media3/common/MediaItem` in the `https://developer.android.com/reference/androidx/media3/transformer/Composition`.

Supported MIME types are:

- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#VIDEO_H263()`
- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#VIDEO_H264()`
- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#VIDEO_H265()`
- `https://developer.android.com/reference/androidx/media3/common/MimeTypes#VIDEO_MP4V()`

If the MIME type is not supported, `https://developer.android.com/reference/androidx/media3/transformer/Transformer` will fallback to a supported MIME type and `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Listener#onFallbackApplied(androidx.media3.transformer.Composition,androidx.media3.transformer.TransformationRequest,androidx.media3.transformer.TransformationRequest)` will be invoked with the fallback value.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html videoMimeType` | The MIME type of the video samples in the output. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/Transformer.Builder` | This builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the video MIME type passed is not a video `https://developer.android.com/reference/androidx/media3/common/MimeTypes`. |