Class Transformer
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.Transformer
-
@Deprecated public final class Transformer extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.A transformer to export media inputs.The same Transformer instance can be used to export multiple inputs (sequentially, not concurrently).
Transformer instances must be accessed from a single application thread. For the vast majority of cases this should be the application's main thread. The thread on which a Transformer instance must be accessed can be explicitly specified by passing a
Looper
when creating the transformer. If no Looper is specified, then the Looper of the thread that theTransformer.Builder
is created on is used, or if that thread does not have a Looper, the Looper of the application's main thread is used. In all cases the Looper of the thread from which the transformer must be accessed can be queried usinggetApplicationLooper()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Transformer.Builder
Deprecated.A builder forTransformer
instances.static interface
Transformer.Listener
Deprecated.A listener for the export events.static interface
Transformer.ProgressState
Deprecated.Progress state.
-
Field Summary
Fields Modifier and Type Field Description static int
PROGRESS_STATE_AVAILABLE
Deprecated.Indicates that the progress is available.static int
PROGRESS_STATE_NO_TRANSFORMATION
Deprecated.UsePROGRESS_STATE_NOT_STARTED
instead.static int
PROGRESS_STATE_NOT_STARTED
Deprecated.Indicates that the corresponding operation hasn't been started.static int
PROGRESS_STATE_UNAVAILABLE
Deprecated.Indicates that the progress is permanently unavailable.static int
PROGRESS_STATE_WAITING_FOR_AVAILABILITY
Deprecated.Indicates that the progress is currently unavailable, but might become available.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addListener(Transformer.Listener listener)
Deprecated.Adds aTransformer.Listener
to listen to the export events.Transformer.Builder
buildUpon()
Deprecated.Returns aTransformer.Builder
initialized with the values of this instance.void
cancel()
Deprecated.Cancels the export that is currently in progress, if any.Looper
getApplicationLooper()
Deprecated.Returns theLooper
associated with the application thread that's used to access the transformer and on which transformer events are received.@com.google.android.exoplayer2.transformer.Transformer.ProgressState int
getProgress(ProgressHolder progressHolder)
Deprecated.Returns the currentTransformer.ProgressState
and updatesprogressHolder
with the current progress if it isavailable
.void
removeAllListeners()
Deprecated.Removes all listeners.void
removeListener(Transformer.Listener listener)
Deprecated.Removes aTransformer.Listener
.void
setListener(Transformer.Listener listener)
Deprecated.void
start(MediaItem mediaItem, String path)
Deprecated.Starts an asynchronous operation to export the givenMediaItem
.void
start(Composition composition, String path)
Deprecated.Starts an asynchronous operation to export the givenComposition
.void
start(EditedMediaItem editedMediaItem, String path)
Deprecated.Starts an asynchronous operation to export the givenEditedMediaItem
.void
startTransformation(MediaItem mediaItem, String path)
Deprecated.Usestart(MediaItem, String)
instead.
-
-
-
Field Detail
-
PROGRESS_STATE_NOT_STARTED
public static final int PROGRESS_STATE_NOT_STARTED
Deprecated.Indicates that the corresponding operation hasn't been started.- See Also:
- Constant Field Values
-
PROGRESS_STATE_NO_TRANSFORMATION
@Deprecated public static final int PROGRESS_STATE_NO_TRANSFORMATION
Deprecated.UsePROGRESS_STATE_NOT_STARTED
instead.- See Also:
- Constant Field Values
-
PROGRESS_STATE_WAITING_FOR_AVAILABILITY
public static final int PROGRESS_STATE_WAITING_FOR_AVAILABILITY
Deprecated.Indicates that the progress is currently unavailable, but might become available.- See Also:
- Constant Field Values
-
PROGRESS_STATE_AVAILABLE
public static final int PROGRESS_STATE_AVAILABLE
Deprecated.Indicates that the progress is available.- See Also:
- Constant Field Values
-
PROGRESS_STATE_UNAVAILABLE
public static final int PROGRESS_STATE_UNAVAILABLE
Deprecated.Indicates that the progress is permanently unavailable.- See Also:
- Constant Field Values
-
-
Method Detail
-
buildUpon
public Transformer.Builder buildUpon()
Deprecated.Returns aTransformer.Builder
initialized with the values of this instance.
-
setListener
@Deprecated public void setListener(Transformer.Listener listener)
Deprecated.
-
addListener
public void addListener(Transformer.Listener listener)
Deprecated.Adds aTransformer.Listener
to listen to the export events.- Parameters:
listener
- ATransformer.Listener
.- Throws:
IllegalStateException
- If this method is called from the wrong thread.
-
removeListener
public void removeListener(Transformer.Listener listener)
Deprecated.Removes aTransformer.Listener
.- Parameters:
listener
- ATransformer.Listener
.- Throws:
IllegalStateException
- If this method is called from the wrong thread.
-
removeAllListeners
public void removeAllListeners()
Deprecated.Removes all listeners.- Throws:
IllegalStateException
- If this method is called from the wrong thread.
-
start
public void start(Composition composition, String path)
Deprecated.Starts an asynchronous operation to export the givenComposition
.This method is under implementation. Only the compositions meeting the below conditions are supported:
- There must be no overlapping track corresponding to the same track type in the output. More precisely, the composition must either contain a single sequence, or contain one audio-only sequence and one video/image-only sequence.
- A sequence cannot contain both video and image input.
- A sequence cannot contain both HDR and SDR video input.
- A sequence cannot have gaps in its video or image samples. In other words, if a sequence contains video or image data, it must contain this type of data in the entire sequence.
- All the
EditedMediaItem
instances in a sequence must have the same audio format. - All the
EditedMediaItem
instances in a sequence must have the same effects applied. - The composition effects must contain no audio effects.
- The composition effects must either contain no video
effects, or exactly one
Presentation
.
The export state is notified through the listener.
Concurrent exports on the same Transformer object are not allowed.
If no custom
Muxer.Factory
is specified, the output is an MP4 file.The output can contain at most one video track and one audio track. Other track types are ignored. For adaptive bitrate inputs, if no custom
AssetLoader.Factory
is specified, the highest bitrate video and audio streams are selected.If exporting the video track entails transcoding, the output frames' dimensions will be swapped if the output video's height is larger than the width. This is to improve compatibility among different device encoders.
- Parameters:
composition
- TheComposition
to export.path
- The path to the output file.- Throws:
IllegalStateException
- If this method is called from the wrong thread.IllegalStateException
- If an export is already in progress.
-
start
public void start(EditedMediaItem editedMediaItem, String path)
Deprecated.Starts an asynchronous operation to export the givenEditedMediaItem
.The export state is notified through the listener.
Concurrent exports on the same Transformer object are not allowed.
If no custom
Muxer.Factory
is specified, the output is an MP4 file.The output can contain at most one video track and one audio track. Other track types are ignored. For adaptive bitrate inputs, if no custom
AssetLoader.Factory
is specified, the highest bitrate video and audio streams are selected.If exporting the video track entails transcoding, the output frames' dimensions will be swapped if the output video's height is larger than the width. This is to improve compatibility among different device encoders.
- Parameters:
editedMediaItem
- TheEditedMediaItem
to export.path
- The path to the output file.- Throws:
IllegalStateException
- If this method is called from the wrong thread.IllegalStateException
- If an export is already in progress.
-
start
public void start(MediaItem mediaItem, String path)
Deprecated.Starts an asynchronous operation to export the givenMediaItem
.The export state is notified through the listener.
Concurrent exports on the same Transformer object are not allowed.
If no custom
Muxer.Factory
is specified, the output is an MP4 file.The output can contain at most one video track and one audio track. Other track types are ignored. For adaptive bitrate inputs, if no custom
AssetLoader.Factory
is specified, the highest bitrate video and audio streams are selected.If exporting the video track entails transcoding, the output frames' dimensions will be swapped if the output video's height is larger than the width. This is to improve compatibility among different device encoders.
- Parameters:
mediaItem
- TheMediaItem
to export.path
- The path to the output file.- Throws:
IllegalArgumentException
- If theMediaItem
is not supported.IllegalStateException
- If this method is called from the wrong thread.IllegalStateException
- If an export is already in progress.
-
startTransformation
@Deprecated @InlineMe(replacement="this.start(mediaItem, path)") public void startTransformation(MediaItem mediaItem, String path)
Deprecated.Usestart(MediaItem, String)
instead.
-
getApplicationLooper
public Looper getApplicationLooper()
Deprecated.Returns theLooper
associated with the application thread that's used to access the transformer and on which transformer events are received.
-
getProgress
public @com.google.android.exoplayer2.transformer.Transformer.ProgressState int getProgress(ProgressHolder progressHolder)
Deprecated.Returns the currentTransformer.ProgressState
and updatesprogressHolder
with the current progress if it isavailable
.After an export completes, this method returns
PROGRESS_STATE_NOT_STARTED
.- Parameters:
progressHolder
- AProgressHolder
, updated to hold the percentage progress ifavailable
.- Returns:
- The
Transformer.ProgressState
. - Throws:
IllegalStateException
- If this method is called from the wrong thread.
-
cancel
public void cancel()
Deprecated.Cancels the export that is currently in progress, if any.The export output file (if any) is not deleted.
- Throws:
IllegalStateException
- If this method is called from the wrong thread.
-
-