# 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)

*** ** * ** ***


```
class Transformer.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

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

## Public constructors

### Builder

```
Builder(context: Context!)
```

Creates a builder with default values.

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

## Public functions

### addListener

```
@CanIgnoreReturnValue
fun addListener(listener: Transformer.Listener!): Transformer.Builder!
```

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

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

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

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

### build

```
fun build(): Transformer!
```

Builds a `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/transformer/Transformer.Builder#experimentalSetMp4EditListTrimEnabled(boolean)` is enabled but the `https://developer.android.com/reference/kotlin/androidx/media3/muxer/Muxer.Factory` does not support writing negative timestamps to an edit list. |

### experimentalSetMaxFramesInEncoder

```
@CanIgnoreReturnValue
@ExperimentalApi
fun experimentalSetMaxFramesInEncoder(maxFramesInEncoder: Int): Transformer.Builder!
```

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

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

The default value is `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `maxFramesInEncoder: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of frames that the video encoder is allowed to process at a time, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if no limit is enforced. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/common/C#INDEX_UNSET()` and is non-positive. |

### experimentalSetMp4EditListTrimEnabled

```
@CanIgnoreReturnValue
@ExperimentalApi
fun experimentalSetMp4EditListTrimEnabled(enabled: Boolean): Transformer.Builder!
```

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/kotlin/androidx/media3/muxer/Muxer.Factory` where `https://developer.android.com/reference/kotlin/androidx/media3/muxer/Muxer.Factory#supportsWritingNegativeTimestampsInEditList()` is false. The `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/transformer/EditedMediaItem` in the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition`).
- Transformer input contains a single `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` but the `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to enable mp4 edit list trimming. |

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

### experimentalSetTrimOptimizationEnabled

```
@CanIgnoreReturnValue
@ExperimentalApi
fun experimentalSetTrimOptimizationEnabled(enabled: Boolean): Transformer.Builder!
```

Sets whether to attempt to optimize trims from the start of the `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/transformer/EditedMediaItem` in the whole `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/media3/transformer/ExportResult#optimizationResult()` will indicate whether the optimization was applied.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to enable trim optimization. |

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

### removeAllListeners

```
@CanIgnoreReturnValue
fun removeAllListeners(): Transformer.Builder!
```

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

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

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

### removeListener

```
@CanIgnoreReturnValue
fun removeListener(listener: Transformer.Listener!): Transformer.Builder!
```

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

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

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

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

### setAssetLoaderFactory

```
@CanIgnoreReturnValue
fun setAssetLoaderFactory(assetLoaderFactory: AssetLoader.Factory!): Transformer.Builder!
```

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

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

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

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

### setAudioMimeType

```
@CanIgnoreReturnValue
fun setAudioMimeType(audioMimeType: String!): Transformer.Builder!
```

Sets the audio `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/common/MediaItem` in the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition`.

Supported MIME types are:

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

If the MIME type is not supported, `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer` will fallback to a supported MIME type and `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `audioMimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The MIME type of the audio samples in the output. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/common/MimeTypes`. |

### setAudioMixerFactory

```
@CanIgnoreReturnValue
fun setAudioMixerFactory(audioMixerFactory: AudioMixer.Factory!): Transformer.Builder!
```

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

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

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

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

### setClock

```
@CanIgnoreReturnValue
@VisibleForTesting
fun setClock(clock: Clock!): Transformer.Builder!
```

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

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

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

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

### setDebugViewProvider

```
@CanIgnoreReturnValue
fun setDebugViewProvider(debugViewProvider: DebugViewProvider!): Transformer.Builder!
```

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/kotlin/androidx/media3/common/DebugViewProvider#NONE()`, which doesn't show any debug info.

Not all exports will result in debug views being populated.

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

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

### setEncoderFactory

```
@CanIgnoreReturnValue
fun setEncoderFactory(encoderFactory: Codec.EncoderFactory!): Transformer.Builder!
```

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

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

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

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

### setEnsureFileStartsOnVideoFrameEnabled

```
@CanIgnoreReturnValue
fun setEnsureFileStartsOnVideoFrameEnabled(enabled: Boolean): Transformer.Builder!
```

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/kotlin/androidx/media3/transformer/Transformer.Builder#experimentalSetTrimOptimizationEnabled(boolean)` or `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#experimentalSetMp4EditListTrimEnabled(boolean)` is set.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to ensure that the file starts on a video frame. |

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

### setFrameProcessorFactory

```
@CanIgnoreReturnValue
@ExperimentalApi
fun setFrameProcessorFactory(frameProcessorFactory: FrameProcessor.Factory!): Transformer.Builder!
```

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

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

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

### setLooper

```
@CanIgnoreReturnValue
fun setLooper(looper: Looper!): Transformer.Builder!
```

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

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

### setMaxDelayBetweenMuxerSamplesMs

```
@CanIgnoreReturnValue
fun setMaxDelayBetweenMuxerSamplesMs(maxDelayBetweenMuxerSamplesMs: Long): Transformer.Builder!
```

Sets the maximum delay allowed between output samples regardless of the track type, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if there is no maximum. The default value is `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `maxDelayBetweenMuxerSamplesMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The maximum delay allowed (in microseconds). |

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

### setMuxerFactory

```
@CanIgnoreReturnValue
fun setMuxerFactory(muxerFactory: Muxer.Factory!): Transformer.Builder!
```

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

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

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

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

### setNativeHardwareBufferHelpers

```
@CanIgnoreReturnValue
@ExperimentalApi
fun setNativeHardwareBufferHelpers(
    hardwareBufferJniWrapper: HardwareBufferJniWrapper!
): Transformer.Builder!
```

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

The default value is `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/transformer/Transformer.Builder#setFrameProcessorFactory(androidx.media3.common.video.FrameProcessor.Factory)` is set.

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

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

### setPortraitEncodingEnabled

```
@CanIgnoreReturnValue
fun setPortraitEncodingEnabled(enabled: Boolean): Transformer.Builder!
```

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 |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to encode portrait videos in portrait orientation. |

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

### setUsePlatformDiagnostics

```
@CanIgnoreReturnValue
fun setUsePlatformDiagnostics(usePlatformDiagnostics: Boolean): Transformer.Builder!
```

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 |
|---|---|
| `usePlatformDiagnostics: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether transformer reports diagnostics data to the Android platform. |

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

### setVideoFrameProcessorFactory

```
@CanIgnoreReturnValue
fun setVideoFrameProcessorFactory(
    videoFrameProcessorFactory: VideoFrameProcessor.Factory!
): Transformer.Builder!
```

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

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

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

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

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

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

### setVideoMimeType

```
@CanIgnoreReturnValue
fun setVideoMimeType(videoMimeType: String!): Transformer.Builder!
```

Sets the video `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/common/MediaItem` in the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition`.

Supported MIME types are:

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

If the MIME type is not supported, `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer` will fallback to a supported MIME type and `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `videoMimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The MIME type of the video samples in the output. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/common/MimeTypes`. |