Class Composition.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.Composition.Builder
-
- Enclosing class:
- Composition
public static final class Composition.Builder extends Object
A builder forComposition
instances.
-
-
Constructor Summary
Constructors Constructor Description Builder(List<EditedMediaItemSequence> sequences)
Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Composition
build()
Builds aComposition
instance.Composition.Builder
experimentalSetForceAudioTrack(boolean forceAudioTrack)
Sets whether the output file should always contain an audio track.Composition.Builder
setEffects(Effects effects)
Sets theEffects
to apply to theComposition
.Composition.Builder
setTransmuxAudio(boolean transmuxAudio)
Sets whether to transmux the media items' audio tracks.Composition.Builder
setTransmuxVideo(boolean transmuxVideo)
Sets whether to transmux the media items' video tracks.
-
-
-
Constructor Detail
-
Builder
public Builder(List<EditedMediaItemSequence> sequences)
Creates an instance.- Parameters:
sequences
- TheEditedMediaItemSequence
instances to compose.MediaItem
instances from different sequences that are overlapping in time will be mixed in the output. This list must not be empty.
-
-
Method Detail
-
setEffects
@CanIgnoreReturnValue public Composition.Builder setEffects(Effects effects)
- Parameters:
effects
- TheComposition
Effects
.- Returns:
- This builder.
-
experimentalSetForceAudioTrack
@CanIgnoreReturnValue public Composition.Builder experimentalSetForceAudioTrack(boolean forceAudioTrack)
Sets whether the output file should always contain an audio track.The default value is
false
.- If
false
:- If the
Composition
export doesn't produce any audio at timestamp 0, but produces audio later on, the export is aborted. - If the
Composition
doesn't produce any audio during the entire export, the output won't contain any audio. - If the
Composition
export produces audio at timestamp 0, the output will contain an audio track.
- If the
- If
true
, the output will always contain an audio track.
Composition
export doesn't produce any audio.The MIME type of the output's audio track can be set using
TransformationRequest.Builder.setAudioMimeType(String)
. The sample rate and channel count can be set by passing relevantAudioProcessor
instances to theComposition
.Forcing an audio track and requesting audio transmuxing are not allowed together because generating silence requires transcoding.
This method is experimental and may be removed or changed without warning.
- Parameters:
forceAudioTrack
- Whether to force an audio track in the output.- Returns:
- This builder.
- If
-
setTransmuxAudio
@CanIgnoreReturnValue public Composition.Builder setTransmuxAudio(boolean transmuxAudio)
Sets whether to transmux the media items' audio tracks.The default value is
false
.If the
Composition
contains oneMediaItem
, the value set is ignored. The audio track will only be transcoded if necessary.If the input
Composition
contains multiple media items, all the audio tracks are transcoded by default. They are all transmuxed iftransmuxAudio
istrue
. Transmuxed tracks must be compatible (typically, all theMediaItem
instances containing the track to transmux are concatenated in a singleEditedMediaItemSequence
and have the same sample format for that track).Requesting audio transmuxing and forcing an audio track are not allowed together because generating silence requires transcoding.
- Parameters:
transmuxAudio
- Whether to transmux the audio tracks.- Returns:
- This builder.
-
setTransmuxVideo
@CanIgnoreReturnValue public Composition.Builder setTransmuxVideo(boolean transmuxVideo)
Sets whether to transmux the media items' video tracks.The default value is
false
.If the
Composition
contains oneMediaItem
, the value set is ignored. The video track will only be transcoded if necessary.If the input
Composition
contains multiple media items, all the video tracks are transcoded by default. They are all transmuxed iftransmuxVideo
istrue
. Transmuxed tracks must be compatible (typically, all theMediaItem
instances containing the track to transmux are concatenated in a singleEditedMediaItemSequence
and have the same sample format for that track).- Parameters:
transmuxVideo
- Whether to transmux the video tracks.- Returns:
- This builder.
-
build
public Composition build()
Builds aComposition
instance.
-
-