Class 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 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().

    • 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_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

      • 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 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, 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 - 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,
                          String 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,
                          String 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.
      • getApplicationLooper

        public 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.
      • 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.