EditedMediaItem.Builder


class EditedMediaItem.Builder


A builder for EditedMediaItem instances.

Summary

Public constructors

Builder(mediaItem: MediaItem!)

Creates an instance.

Public functions

EditedMediaItem!

Builds an EditedMediaItem instance.

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

Sets the MediaItem duration in the output, in microseconds.

EditedMediaItem.Builder!

Sets the Effects to apply to the MediaItem.

EditedMediaItem.Builder!

Sets whether to flatten the MediaItem if it contains slow motion markers.

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

Sets the MediaItem frame rate in the output video, in frames per second.

EditedMediaItem.Builder!

Sets whether to remove the audio from the MediaItem.

EditedMediaItem.Builder!

Sets whether to remove the video from the MediaItem.

Public constructors

Builder

Builder(mediaItem: MediaItem!)

Creates an instance.

For image inputs:

Parameters
mediaItem: MediaItem!

The MediaItem on which transformations are applied.

Public functions

build

fun build(): EditedMediaItem!

Builds an EditedMediaItem instance.

setDurationUs

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

Sets the MediaItem duration in the output, in microseconds.

For export, this should be set for non-image inputs that don't have an intrinsic duration (e.g. raw video data). It will be ignored for inputs that do have an intrinsic duration (e.g. encoded video data from input file).

For preview, this should be set for all non-image inputs (i.e. audio and video input).

This duration doesn't need to be set for images, because the default value is the 's image duration.

If clipping is applied, this should be the duration before clipping.

Parameters
durationUs: @IntRange(from = 1) Long

The duration, in microseconds.

Returns
EditedMediaItem.Builder!

This builder.

setEffects

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

Sets the Effects to apply to the MediaItem.

Callers should not interact with underlying audioProcessors.

The default value is EMPTY.

Parameters
effects: Effects!

The Effects to apply.

Returns
EditedMediaItem.Builder!

This builder.

setFlattenForSlowMotion

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

Sets whether to flatten the MediaItem if it contains slow motion markers.

The default value is false.

See flattenForSlowMotion for more information about slow motion flattening.

If using an ExoPlayerAssetLoader.Factory with a provided , make sure that FLAG_READ_SEF_DATA is set on the Mp4Extractor used. Otherwise, the slow motion metadata will be ignored and the input won't be flattened.

Slow motion flattening is only supported when the Composition contains exactly one MediaItem.

Using slow motion flattening together with MediaItem.ClippingConfiguration is not supported yet.

Parameters
flattenForSlowMotion: Boolean

Whether to flatten for slow motion.

Returns
EditedMediaItem.Builder!

This builder.

setFrameRate

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

Sets the MediaItem frame rate in the output video, in frames per second.

This should be set for inputs that don't have an intrinsic frame rate (e.g., images). It will be ignored for inputs that do have an intrinsic frame rate (e.g., 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.

No frame rate is set by default.

Parameters
frameRate: @IntRange(from = 0) Int

The frame rate, in frames per second.

Returns
EditedMediaItem.Builder!

This builder.

setRemoveAudio

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

Sets whether to remove the audio from the MediaItem.

The default value is false.

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

Parameters
removeAudio: Boolean

Whether to remove the audio.

Returns
EditedMediaItem.Builder!

This builder.

setRemoveVideo

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

Sets whether to remove the video from the MediaItem.

The default value is false.

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

Parameters
removeVideo: Boolean

Whether to remove the video.

Returns
EditedMediaItem.Builder!

This builder.