Class EditedMediaItem.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.EditedMediaItem.Builder
-
- Enclosing class:
- EditedMediaItem
public static final class EditedMediaItem.Builder extends Object
A builder forEditedMediaItem
instances.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EditedMediaItem
build()
Builds anEditedMediaItem
instance.EditedMediaItem.Builder
setDurationUs(long durationUs)
Sets the duration of the output video in microseconds.EditedMediaItem.Builder
setEffects(Effects effects)
EditedMediaItem.Builder
setFlattenForSlowMotion(boolean flattenForSlowMotion)
Sets whether to flatten theMediaItem
if it contains slow motion markers.EditedMediaItem.Builder
setFrameRate(int frameRate)
Sets the frame rate of the output video in frames per second.EditedMediaItem.Builder
setRemoveAudio(boolean removeAudio)
Sets whether to remove the audio from theMediaItem
.EditedMediaItem.Builder
setRemoveVideo(boolean removeVideo)
Sets whether to remove the video from theMediaItem
.
-
-
-
Constructor Detail
-
Builder
public Builder(MediaItem mediaItem)
Creates an instance.For image inputs, the values passed into
setRemoveAudio(boolean)
,setRemoveVideo(boolean)
andsetFlattenForSlowMotion(boolean)
will be ignored.- Parameters:
mediaItem
- TheMediaItem
on which transformations are applied.
-
-
Method Detail
-
setRemoveAudio
@CanIgnoreReturnValue public EditedMediaItem.Builder setRemoveAudio(boolean removeAudio)
Sets whether to remove the audio from theMediaItem
.The default value is
false
.The audio and video cannot both be removed because the output would not contain any samples.
- Parameters:
removeAudio
- Whether to remove the audio.- Returns:
- This builder.
-
setRemoveVideo
@CanIgnoreReturnValue public EditedMediaItem.Builder setRemoveVideo(boolean removeVideo)
Sets whether to remove the video from theMediaItem
.The default value is
false
.The audio and video cannot both be removed because the output would not contain any samples.
- Parameters:
removeVideo
- Whether to remove the video.- Returns:
- This builder.
-
setFlattenForSlowMotion
@CanIgnoreReturnValue public EditedMediaItem.Builder setFlattenForSlowMotion(boolean flattenForSlowMotion)
Sets whether to flatten theMediaItem
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 providedMediaSource.Factory
, make sure thatMp4Extractor.FLAG_READ_SEF_DATA
is set on theMp4Extractor
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 oneMediaItem
.Using slow motion flattening together with
MediaItem.ClippingConfiguration
is not supported yet.- Parameters:
flattenForSlowMotion
- Whether to flatten for slow motion.- Returns:
- This builder.
-
setDurationUs
@CanIgnoreReturnValue public EditedMediaItem.Builder setDurationUs(long durationUs)
Sets the duration of the output video in microseconds.This should be set for inputs that don't have an implicit duration (e.g. images). It will be ignored for inputs that do have an implicit duration (e.g. video).
No duration is set by default.
-
setFrameRate
@CanIgnoreReturnValue public EditedMediaItem.Builder setFrameRate(@IntRange(from=0L) 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.
-
setEffects
@CanIgnoreReturnValue public EditedMediaItem.Builder setEffects(Effects effects)
- Parameters:
effects
- TheEffects
to apply.- Returns:
- This builder.
-
build
public EditedMediaItem build()
Builds anEditedMediaItem
instance.
-
-