# EditedMediaItem.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/EditedMediaItem.java+class:androidx.media3.transformer.EditedMediaItem.Builder)

*** ** * ** ***


```
class EditedMediaItem.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#Builder(androidx.media3.common.MediaItem)(mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!)` Creates an instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem!` | `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#build()()` Builds an `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem` instance. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setDurationUs(long)(durationUs: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the duration in microseconds of the source media represented by the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setEffects(androidx.media3.transformer.Effects)(effects: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Effects!)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Effects` to apply to the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setFlattenForSlowMotion(boolean)(flattenForSlowMotion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to flatten the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` if it contains slow motion markers. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setFrameRate(int)(frameRate: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` frame rate in the output video, in frames per second. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setRemoveAudio(boolean)(removeAudio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to remove the audio from the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setRemoveVideo(boolean)(removeVideo: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to remove the video from the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/ExperimentalApi @https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setSpeed(androidx.media3.common.SpeedParameters)(parameters: https://developer.android.com/reference/kotlin/androidx/media3/common/SpeedParameters!)` Sets a `https://developer.android.com/reference/kotlin/androidx/media3/common/SpeedParameters` instance to control the presentation speed of the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setSpeed(androidx.media3.common.audio.SpeedProvider)(provider: https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider!)` Sets a `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider` to control the presentation speed of the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem`. |

## Public constructors

### Builder

```
Builder(mediaItem: MediaItem!)
```

Creates an instance.

For image inputs:

- The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.Builder#setImageDurationMs(long)` should always be set.
- The values passed into `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setRemoveAudio(boolean)`, `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setRemoveVideo(boolean)` and `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setFlattenForSlowMotion(boolean)` will be ignored.
- For multi-picture formats (e.g. gifs), a single image frame from the container is displayed if the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/DefaultAssetLoaderFactory` is used.

| Parameters |
|---|---|
| `mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` on which transformations are applied. |

## Public functions

### build

```
fun build(): EditedMediaItem!
```

Builds an `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem` instance.

### setDurationUs

```
@CanIgnoreReturnValue
fun setDurationUs(durationUs: @IntRange(from = 1) Long): EditedMediaItem.Builder!
```

Sets the duration in microseconds of the source media represented by the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

The provided duration should match the duration of the source media before applying any `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.ClippingConfiguration` or `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setSpeed(androidx.media3.common.audio.SpeedProvider)`.

Setting the duration is optional in the following cases:

- The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` represents an image. The default image duration set via `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.Builder#setImageDurationMs(long)`.
- On `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Transformer`, when the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` has an intrinsic duration (e.g. encoded video/audio data from an input file).

| Parameters |
|---|---|
| `durationUs: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration, in microseconds. |

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

### setEffects

```
@CanIgnoreReturnValue
fun setEffects(effects: Effects!): EditedMediaItem.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Effects` to apply to the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

Callers should not interact with underlying `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Effects#audioProcessors()`.

The default value is `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Effects#EMPTY()`.

| Parameters |
|---|---|
| `effects: https://developer.android.com/reference/kotlin/androidx/media3/transformer/Effects!` | The `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Effects` to apply. |

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

### setFlattenForSlowMotion

```
@CanIgnoreReturnValue
fun setFlattenForSlowMotion(flattenForSlowMotion: Boolean): EditedMediaItem.Builder!
```

Sets whether to flatten the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` if it contains slow motion markers.

The default value is `false`.

See `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#flattenForSlowMotion()` for more information about slow motion flattening.

If using an `https://developer.android.com/reference/kotlin/androidx/media3/transformer/ExoPlayerAssetLoader.Factory` with a provided `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.Factory`, make sure that `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/Mp4Extractor#FLAG_READ_SEF_DATA()` is set on the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/Mp4Extractor` used. Otherwise, the slow motion metadata will be ignored and the input won't be flattened.

Slow motion flattening is only supported when the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Composition` contains exactly one `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

Using slow motion flattening together with `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.ClippingConfiguration` is not supported yet.

| Parameters |
|---|---|
| `flattenForSlowMotion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to flatten for slow motion. |

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

### setFrameRate

```
@CanIgnoreReturnValue
fun setFrameRate(frameRate: @IntRange(from = 0) Int): EditedMediaItem.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` frame rate in the output video, in frames per second.

- For inputs that don't have an intrinsic frame rate (e.g., images), this value determines the frame rate of the output video. For images, the frame rate depends on factors such as desired look, output format requirement, and whether the content is static or dynamic (e.g., animation). However, 30 fps is suitable for most use cases.
- For inputs that do have an intrinsic frame rate (e.g., video), this value acts as a maximum frame rate. If the intrinsic frame rate is higher than the value set here, frames will be dropped to achieve the specified maximum frame rate in the output. If the intrinsic frame rate is lower, this parameter has no effect. Setting the max frame rate is particularly important when increasing media speed using the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setSpeed(androidx.media3.common.audio.SpeedProvider)` API. Increasing media speed adjusts video sample timestamps to the new rate, resulting in a higher effective output frame rate. By setting a maximum frame rate, you can prevent the output from having an excessively high frame rate.

No frame rate is set by default.

| Parameters |
|---|---|
| `frameRate: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The frame rate, in frames per second. |

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

### setRemoveAudio

```
@CanIgnoreReturnValue
fun setRemoveAudio(removeAudio: Boolean): EditedMediaItem.Builder!
```

Sets whether to remove the audio from the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

The default value is `false`.

The audio and video cannot both be removed because the output would not contain any samples.

| Parameters |
|---|---|
| `removeAudio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to remove the audio. |

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

### setRemoveVideo

```
@CanIgnoreReturnValue
fun setRemoveVideo(removeVideo: Boolean): EditedMediaItem.Builder!
```

Sets whether to remove the video from the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

The default value is `false`.

The audio and video cannot both be removed because the output would not contain any samples.

| Parameters |
|---|---|
| `removeVideo: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to remove the video. |

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

### setSpeed

```
@ExperimentalApi
@CanIgnoreReturnValue
fun setSpeed(parameters: SpeedParameters!): EditedMediaItem.Builder!
```

Sets a `https://developer.android.com/reference/kotlin/androidx/media3/common/SpeedParameters` instance to control the presentation speed of the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem`.

If a `https://developer.android.com/reference/kotlin/androidx/media3/common/SpeedParameters` instance is set, speed changing `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setEffects(androidx.media3.transformer.Effects)` are not allowed.

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

### setSpeed

```
@CanIgnoreReturnValue
fun setSpeed(provider: SpeedProvider!): EditedMediaItem.Builder!
```

Sets a `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider` to control the presentation speed of the `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem`.

If a `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider` is set, speed changing `https://developer.android.com/reference/kotlin/androidx/media3/transformer/EditedMediaItem.Builder#setEffects(androidx.media3.transformer.Effects)` are not allowed.

This method is identical to `setSpeed(new SpeedParameters(provider, false))`.

The default value is `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider#DEFAULT()`, which represents an unmodified speed.

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