Back to Exoplayer

Transformer (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/transformer/Transformer.html

latest19.2 KB
Original Source

Package com.google.android.exoplayer2.transformer

Class Transformer


[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classTransformerextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")

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 the Transformer.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 using getApplicationLooper().

Nested Class Summary

Nested Classes | Modifier and Type | Class | Description | | --- | --- | --- | | static class | Transformer.Builder | Deprecated.

A builder for Transformer 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. Use PROGRESS_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 a Transformer.Listener to listen to the export events. | | Transformer.Builder | buildUpon() | Deprecated.

Returns a Transformer.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 the Looper 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 current Transformer.ProgressState and updates progressHolder with the current progress if it is available. | | void | removeAllListeners() | Deprecated.

Removes all listeners. | | void | removeListener​(Transformer.Listener listener) | Deprecated.

Removes a Transformer.Listener. | | void | setListener​(Transformer.Listener listener) | Deprecated. Use addListener(Listener), removeListener(Listener) or removeAllListeners() instead.

| | void | start​(MediaItem mediaItem, String path) | Deprecated.

Starts an asynchronous operation to export the given MediaItem. | | void | start​(Composition composition, String path) | Deprecated.

Starts an asynchronous operation to export the given Composition. | | void | start​(EditedMediaItem editedMediaItem, String path) | Deprecated.

Starts an asynchronous operation to export the given EditedMediaItem. | | void | startTransformation​(MediaItem mediaItem, String path) | Deprecated. Use start(MediaItem, String) instead.

|

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

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](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public static final int PROGRESS_STATE_NO_TRANSFORMATION

Deprecated. Use PROGRESS_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](Transformer.Builder.html "class in com.google.android.exoplayer2.transformer")buildUpon()

Deprecated.

Returns a Transformer.Builder initialized with the values of this instance.

- 

setListener

[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public void setListener​([Transformer.Listener](Transformer.Listener.html "interface in com.google.android.exoplayer2.transformer")listener)

Deprecated. Use addListener(Listener), removeListener(Listener) or removeAllListeners() instead.

- 

addListener

public void addListener​([Transformer.Listener](Transformer.Listener.html "interface in com.google.android.exoplayer2.transformer")listener)

Deprecated.

Adds a Transformer.Listener to listen to the export events. Parameters:listener - A Transformer.Listener.Throws:IllegalStateException - If this method is called from the wrong thread.

- 

removeListener

public void removeListener​([Transformer.Listener](Transformer.Listener.html "interface in com.google.android.exoplayer2.transformer")listener)

Deprecated.

Removes a Transformer.Listener. Parameters:listener - A Transformer.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.html "class in com.google.android.exoplayer2.transformer")composition,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")path)

Deprecated.

Starts an asynchronous operation to export the given Composition.

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](EditedMediaItemSequence.html "class in com.google.android.exoplayer2.transformer"), 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`](EditedMediaItem.html "class in com.google.android.exoplayer2.transformer") instances in a sequence must have the same audio format. 
  - All the [`EditedMediaItem`](EditedMediaItem.html "class in com.google.android.exoplayer2.transformer") instances in a sequence must have the same effects applied. 
  - The [composition effects](Composition.html#effects) must contain no [audio effects](Effects.html#audioProcessors). 
  - The composition effects must either contain no [video effects](Effects.html#videoEffects), or exactly one [`Presentation`](../effect/Presentation.html "class in com.google.android.exoplayer2.effect"). 

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 - The Composition 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.html "class in com.google.android.exoplayer2.transformer")editedMediaItem,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")path)

Deprecated.

Starts an asynchronous operation to export the given EditedMediaItem.

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 - The EditedMediaItem 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.html "class in com.google.android.exoplayer2")mediaItem,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")path)

Deprecated.

Starts an asynchronous operation to export the given MediaItem.

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 - The MediaItem to export.path - The path to the output file.Throws:IllegalArgumentException - If the MediaItem is not supported.IllegalStateException - If this method is called from the wrong thread.IllegalStateException - If an export is already in progress.

- 

startTransformation

[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")@InlineMe(replacement="this.start(mediaItem, path)")
public void startTransformation​([MediaItem](../MediaItem.html "class in com.google.android.exoplayer2")mediaItem,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")path)

Deprecated. Use start(MediaItem, String) instead.

- 

getApplicationLooper

public[Looper](https://developer.android.com/reference/android/os/Looper.html "class or interface in android.os")getApplicationLooper()

Deprecated.

Returns the Looper 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.html "class in com.google.android.exoplayer2.transformer")progressHolder)

Deprecated.

Returns the current Transformer.ProgressState and updates progressHolder with the current progress if it is available.

After an export completes, this method returns PROGRESS_STATE_NOT_STARTED.

Parameters:progressHolder - A ProgressHolder, updated to hold the percentage progress if available.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.