EditedMediaItem.Builder


public final class EditedMediaItem.Builder


A builder for EditedMediaItem instances.

Summary

Public constructors

Builder(MediaItem mediaItem)

Creates an instance.

Public methods

EditedMediaItem

Builds an EditedMediaItem instance.

EditedMediaItem.Builder
@CanIgnoreReturnValue
setDurationUs(@IntRange(from = 1) long durationUs)

Sets the duration of the output video in microseconds.

EditedMediaItem.Builder

Sets the Effects to apply to the MediaItem.

EditedMediaItem.Builder
@CanIgnoreReturnValue
setFlattenForSlowMotion(boolean flattenForSlowMotion)

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

EditedMediaItem.Builder
@CanIgnoreReturnValue
setFrameRate(@IntRange(from = 0) int frameRate)

Sets the frame rate of the output video in frames per second.

EditedMediaItem.Builder
@CanIgnoreReturnValue
setRemoveAudio(boolean removeAudio)

Sets whether to remove the audio from the MediaItem.

EditedMediaItem.Builder
@CanIgnoreReturnValue
setRemoveVideo(boolean removeVideo)

Sets whether to remove the video from the MediaItem.

Public constructors

Builder

public Builder(MediaItem mediaItem)

Creates an instance.

For image inputs, the values passed into setRemoveAudio, setRemoveVideo and setFlattenForSlowMotion will be ignored. For multi-picture formats (e.g. gifs), a single image frame from the container is displayed if the DefaultAssetLoaderFactory is used.

Parameters
MediaItem mediaItem

The MediaItem on which transformations are applied.

Public methods

build

public EditedMediaItem build()

Builds an EditedMediaItem instance.

setDurationUs

@CanIgnoreReturnValue
public EditedMediaItem.Builder setDurationUs(@IntRange(from = 1) long durationUs)

Sets the duration of the output video in microseconds.

For an input that doesn't have an intrinsic duration (e.g. images), this should be the desired presentation duration. Otherwise, this should be the duration of the full content that the media URI resolves to, before clippingConfiguration is applied.

No duration is set by default.

setEffects

@CanIgnoreReturnValue
public EditedMediaItem.Builder setEffects(Effects effects)

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
public EditedMediaItem.Builder setFlattenForSlowMotion(boolean flattenForSlowMotion)

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
boolean flattenForSlowMotion

Whether to flatten for slow motion.

Returns
EditedMediaItem.Builder

This builder.

setFrameRate

@CanIgnoreReturnValue
public EditedMediaItem.Builder setFrameRate(@IntRange(from = 0) int frameRate)

Sets the frame rate of the output video in frames per second.

This should be set for inputs that don't have an implicit frame rate (e.g. images). It will be ignored for inputs that do have an implicit frame rate (e.g. video).

No frame rate is set by default.

setRemoveAudio

@CanIgnoreReturnValue
public EditedMediaItem.Builder setRemoveAudio(boolean removeAudio)

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
boolean removeAudio

Whether to remove the audio.

Returns
EditedMediaItem.Builder

This builder.

setRemoveVideo

@CanIgnoreReturnValue
public EditedMediaItem.Builder setRemoveVideo(boolean removeVideo)

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
boolean removeVideo

Whether to remove the video.

Returns
EditedMediaItem.Builder

This builder.