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
Looperwhen creating the transformer. If no Looper is specified, then the Looper of the thread that theTransformer.Builderis 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 classTransformer.BuilderDeprecated.A builder forTransformerinstances.static interfaceTransformer.ListenerDeprecated.A listener for the export events.static interfaceTransformer.ProgressStateDeprecated.Progress state.
-
Field Summary
Fields Modifier and Type Field Description static intPROGRESS_STATE_AVAILABLEDeprecated.Indicates that the progress is available.static intPROGRESS_STATE_NO_TRANSFORMATIONDeprecated.UsePROGRESS_STATE_NOT_STARTEDinstead.static intPROGRESS_STATE_NOT_STARTEDDeprecated.Indicates that the corresponding operation hasn't been started.static intPROGRESS_STATE_UNAVAILABLEDeprecated.Indicates that the progress is permanently unavailable.static intPROGRESS_STATE_WAITING_FOR_AVAILABILITYDeprecated.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 voidaddListener(Transformer.Listener listener)Deprecated.Adds aTransformer.Listenerto listen to the export events.Transformer.BuilderbuildUpon()Deprecated.Returns aTransformer.Builderinitialized with the values of this instance.voidcancel()Deprecated.Cancels the export that is currently in progress, if any.LoopergetApplicationLooper()Deprecated.Returns theLooperassociated 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 intgetProgress(ProgressHolder progressHolder)Deprecated.Returns the currentTransformer.ProgressStateand updatesprogressHolderwith the current progress if it isavailable.voidremoveAllListeners()Deprecated.Removes all listeners.voidremoveListener(Transformer.Listener listener)Deprecated.Removes aTransformer.Listener.voidsetListener(Transformer.Listener listener)Deprecated.voidstart(MediaItem mediaItem, String path)Deprecated.Starts an asynchronous operation to export the givenMediaItem.voidstart(Composition composition, String path)Deprecated.Starts an asynchronous operation to export the givenComposition.voidstart(EditedMediaItem editedMediaItem, String path)Deprecated.Starts an asynchronous operation to export the givenEditedMediaItem.voidstartTransformation(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_STARTEDinstead.- 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.Builderinitialized 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.Listenerto 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
EditedMediaIteminstances in a sequence must have the same audio format. - All the
EditedMediaIteminstances 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.Factoryis 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.Factoryis 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- TheCompositionto 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.Factoryis 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.Factoryis 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- TheEditedMediaItemto 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.Factoryis 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.Factoryis 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- TheMediaItemto export.path- The path to the output file.- Throws:
IllegalArgumentException- If theMediaItemis 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 theLooperassociated 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.ProgressStateand updatesprogressHolderwith 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.
-
-