# Transformer

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)

*** ** * ** ***


```
@UnstableApi
class Transformer
```

<br />

*** ** * ** ***

A transformer to export media inputs.

The same Transformer instance can be used to export multiple inputs (sequentially, not concurrently).

Transformer instances must be accessed from a single application thread. For the vast majority of cases this should be the application's main thread. The thread on which a Transformer instance must be accessed can be explicitly specified by passing a `https://developer.android.com/reference/android/os/Looper.html` when creating the transformer. If no Looper is specified, then the Looper of the thread that the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder` is created on is used, or if that thread does not have a Looper, the Looper of the application's main thread is used. In all cases the Looper of the thread from which the transformer must be accessed can be queried using `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#getApplicationLooper()`.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder` A builder for `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer` instances. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Listener` A listener for the export events. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.ProgressState` Progress state. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#DEFAULT_MAX_DELAY_BETWEEN_MUXER_SAMPLES_MS()` The default value for the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setMaxDelayBetweenMuxerSamplesMs(long)`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE() = 2` Indicates that the progress is available. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_NOT_STARTED() = 0` Indicates that the corresponding operation hasn't been started. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_UNAVAILABLE() = 3` Indicates that the progress is permanently unavailable. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_WAITING_FOR_AVAILABILITY() = 1` Indicates that the progress is currently unavailable, but might become available. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#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.Builder!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#buildUpon()()` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder` initialized with the values of this instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#cancel()()` Cancels the export that is currently in progress, if any. |
| `https://developer.android.com/reference/android/os/Looper.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#getApplicationLooper()()` Returns the `https://developer.android.com/reference/android/os/Looper.html` associated with the application thread that's used to access the transformer and on which transformer events are received. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.ProgressState https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#getProgress(androidx.media3.transformer.ProgressHolder)(progressHolder: https://developer.android.com/reference/kotlin/androidx/media3/transformer/ProgressHolder!)` Returns the current `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.ProgressState` and updates `progressHolder` with the current progress if it is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#removeAllListeners()()` Removes all `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Listener`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#resume(androidx.media3.transformer.Composition,java.lang.String,java.lang.String)( composition: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition!, outputFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, oldFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html! )` Resumes a previously `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#cancel()` export. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#start(androidx.media3.transformer.Composition,androidx.media3.transformer.TransformerOutput)(composition: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition!, output: https://developer.android.com/reference/kotlin/androidx/media3/transformer/TransformerOutput!)` Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` to a `https://developer.android.com/reference/kotlin/androidx/media3/transformer/TransformerOutput`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#start(androidx.media3.transformer.Composition,java.lang.String)(composition: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition!, path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#start(androidx.media3.transformer.EditedMediaItem,java.lang.String)(editedMediaItem: https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem!, path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#start(androidx.media3.common.MediaItem,java.lang.String)(mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!, path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |

## Constants

### DEFAULT_MAX_DELAY_BETWEEN_MUXER_SAMPLES_MS

```
const val DEFAULT_MAX_DELAY_BETWEEN_MUXER_SAMPLES_MS: Long
```

The default value for the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setMaxDelayBetweenMuxerSamplesMs(long)`.

### PROGRESS_STATE_AVAILABLE

```
const val PROGRESS_STATE_AVAILABLE = 2: Int
```

Indicates that the progress is available.

### PROGRESS_STATE_NOT_STARTED

```
const val PROGRESS_STATE_NOT_STARTED = 0: Int
```

Indicates that the corresponding operation hasn't been started.

### PROGRESS_STATE_UNAVAILABLE

```
const val PROGRESS_STATE_UNAVAILABLE = 3: Int
```

Indicates that the progress is permanently unavailable.

### PROGRESS_STATE_WAITING_FOR_AVAILABILITY

```
const val PROGRESS_STATE_WAITING_FOR_AVAILABILITY = 1: Int
```

Indicates that the progress is currently unavailable, but might become available.

## Public functions

### addListener

```
fun addListener(listener: Transformer.Listener!): Unit
```

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

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |

### buildUpon

```
fun buildUpon(): Transformer.Builder!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder` initialized with the values of this instance.

### cancel

```
fun cancel(): Unit
```

Cancels the export that is currently in progress, if any.

The export output file (if any) is not deleted.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |

### getApplicationLooper

```
fun getApplicationLooper(): Looper!
```

Returns the `https://developer.android.com/reference/android/os/Looper.html` associated with the application thread that's used to access the transformer and on which transformer events are received.

### getProgress

```
@Transformer.ProgressState
fun getProgress(progressHolder: ProgressHolder!): Int
```

Returns the current `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.ProgressState` and updates `progressHolder` with the current progress if it is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`.

If the export is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#resume(androidx.media3.transformer.Composition,java.lang.String,java.lang.String)`, this method returns `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_UNAVAILABLE()`.

After an export `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Listener#onCompleted(androidx.media3.transformer.Composition,androidx.media3.transformer.ExportResult)`, this method returns `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_NOT_STARTED()`.

| Parameters |
|---|---|
| `progressHolder: https://developer.android.com/reference/kotlin/androidx/media3/transformer/ProgressHolder!` | A `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ProgressHolder`, updated to hold the percentage progress if `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#PROGRESS_STATE_AVAILABLE()`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.ProgressState`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |

### removeAllListeners

```
fun removeAllListeners(): Unit
```

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |

### removeListener

```
fun removeListener(listener: Transformer.Listener!): Unit
```

Removes a `https://developer.android.com/reference/kotlin/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`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |

### resume

```
fun resume(
    composition: Composition!,
    outputFilePath: String!,
    oldFilePath: String!
): Unit
```

Resumes a previously `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer#cancel()` export.

An export can be resumed only when:

- The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` contains a single `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItemSequence` having continuous audio and video tracks.
- The output is an MP4 file.
- The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` and `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem` instances do not contain speed changing effects.

Note that export optimizations (such as `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#experimentalSetTrimOptimizationEnabled(boolean)`) will not be applied upon resumption.

| Parameters |
|---|---|
| `composition: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition!` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` to resume export. |
| `outputFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The path to the output file. This must be different from the output path of the cancelled export. |
| `oldFilePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The output path of the the cancelled export. |

### start

```
fun start(composition: Composition!, output: TransformerOutput!): Unit
```

Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` to a `https://developer.android.com/reference/kotlin/androidx/media3/transformer/TransformerOutput`.

The export state is notified through the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#addListener(androidx.media3.transformer.Transformer.Listener)`.

Concurrent exports on the same Transformer object are not allowed.

If no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setMuxerFactory(androidx.media3.muxer.Muxer.Factory)` is specified, the output is an MP4 file.

The output can contain at most one video track and one audio track. Other track types are ignored. For adaptive bitrate inputs, if no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setAssetLoaderFactory(androidx.media3.transformer.AssetLoader.Factory)` is specified, the highest bitrate video and audio streams are selected.

If exporting the video track entails transcoding, the output frames' dimensions will be swapped if the output video's height is larger than the width. This is to improve compatibility among different device encoders.

| Parameters |
|---|---|
| `composition: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition!` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` to export. |
| `output: https://developer.android.com/reference/kotlin/androidx/media3/transformer/TransformerOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/TransformerOutput` destination. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If an export is already in progress. |

### start

```
fun start(composition: Composition!, path: String!): Unit
```

Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition`.

The first `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem` in the first `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItemSequence` that has a given `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType` will determine the output format for that track, unless the format is set when `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#build()` the `Transformer`. For example, consider the following composition

```kotlin
  Composition {
    EditedMediaItemSequence {
      [ImageMediaItem, VideoMediaItem]
    },
    EditedMediaItemSequence {
      [AudioMediaItem]
    },
  }
```
The video format will be determined by the `ImageMediaItem` in the first `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItemSequence`, while the audio format will be determined by the `
AudioMediaItem` in the second `EditedMediaItemSequence`.

Some `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` are not supported yet. More specifically, `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItemSequence` within the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` must meet the following conditions:

- The tracks present in the output of a sequence are determined by the `trackTypes` parameter of the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItemSequence.Builder`. Tracks of types not present in `trackTypes` will be dropped. If an `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem` within a sequence does not contain a track of a declared type, silent audio or blank video will be generated.
- If a sequence starts with an HDR `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem`, all the following items in the sequence must be HDR.
- All `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem` containing audio data must output 16 bit PCM audio with the same number of channels. This can be done by adding a `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/ToInt16PcmAudioProcessor` and/or a `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/ChannelMixingAudioProcessor` to the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem#effects()`.

The export state is notified through the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#addListener(androidx.media3.transformer.Transformer.Listener)`.

Concurrent exports on the same Transformer object are not allowed.

If no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setMuxerFactory(androidx.media3.muxer.Muxer.Factory)` is specified, the output is an MP4 file.

The output can contain at most one video track and one audio track. Other track types are ignored. For adaptive bitrate inputs, if no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setAssetLoaderFactory(androidx.media3.transformer.AssetLoader.Factory)` is specified, the highest bitrate video and audio streams are selected.

If exporting the video track entails transcoding, the output frames' dimensions will be swapped if the output video's height is larger than the width. This is to improve compatibility among different device encoders.

| Parameters |
|---|---|
| `composition: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition!` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` to export. |
| `path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The path to the output file. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If an export is already in progress. |

### start

```
fun start(editedMediaItem: EditedMediaItem!, path: String!): Unit
```

Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem`.

The export state is notified through the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#addListener(androidx.media3.transformer.Transformer.Listener)`.

Concurrent exports on the same Transformer object are not allowed.

If no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setMuxerFactory(androidx.media3.muxer.Muxer.Factory)` is specified, the output is an MP4 file.

The output can contain at most one video track and one audio track. Other track types are ignored. For adaptive bitrate inputs, if no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setAssetLoaderFactory(androidx.media3.transformer.AssetLoader.Factory)` is specified, the highest bitrate video and audio streams are selected.

If exporting the video track entails transcoding, the output frames' dimensions will be swapped if the output video's height is larger than the width. This is to improve compatibility among different device encoders.

| Parameters |
|---|---|
| `editedMediaItem: https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem!` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem` to export. |
| `path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The path to the output file. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If an export is already in progress. |

### start

```
fun start(mediaItem: MediaItem!, path: String!): Unit
```

Starts an asynchronous operation to export the given `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

The export state is notified through the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#addListener(androidx.media3.transformer.Transformer.Listener)`.

Concurrent exports on the same Transformer object are not allowed.

If no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setMuxerFactory(androidx.media3.muxer.Muxer.Factory)` is specified, the output is an MP4 file.

The output can contain at most one video track and one audio track. Other track types are ignored. For adaptive bitrate inputs, if no custom `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer.Builder#setAssetLoaderFactory(androidx.media3.transformer.AssetLoader.Factory)` is specified, the highest bitrate video and audio streams are selected.

If exporting the video track entails transcoding, the output frames' dimensions will be swapped if the output video's height is larger than the width. This is to improve compatibility among different device encoders.

| Parameters |
|---|---|
| `mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` to export. |
| `path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The path to the output file. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` is not supported. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If this method is called from the wrong thread. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If an export is already in progress. |