Class Mp4Muxer


  • @Deprecated
    public final class Mp4Muxer
    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 muxer for creating an MP4 container file.

    The muxer supports writing H264, H265 and AV1 video, AAC audio and metadata.

    All the operations are performed on the caller thread.

    To create an MP4 container file, the caller must:

    Some key points:

    • Tracks can be added at any point, even after writing some samples to other tracks.
    • The caller is responsible for ensuring that samples of different track types are well interleaved by calling writeSampleData(TrackToken, ByteBuffer, BufferInfo) in an order that interleaves samples from different tracks.
    • When writing a file, if an error occurs and the muxer is not closed, then the output MP4 file may still have some partial data.
    • Field Detail

      • LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME

        public static final int LAST_FRAME_DURATION_BEHAVIOR_INSERT_SHORT_FRAME
        Deprecated.
        Insert a zero-length last sample.
        See Also:
        Constant Field Values
      • LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION

        public static final int LAST_FRAME_DURATION_BEHAVIOR_DUPLICATE_PREV_DURATION
        Deprecated.
        Use the difference between the last timestamp and the one before that as the duration of the last sample.
        See Also:
        Constant Field Values
      • SUPPORTED_VIDEO_SAMPLE_MIME_TYPES

        public static final ImmutableList<String> SUPPORTED_VIDEO_SAMPLE_MIME_TYPES
        Deprecated.
        A list of supported video sample mime types.
      • SUPPORTED_AUDIO_SAMPLE_MIME_TYPES

        public static final ImmutableList<String> SUPPORTED_AUDIO_SAMPLE_MIME_TYPES
        Deprecated.
        A list of supported audio sample mime types.
    • Method Detail

      • setOrientation

        public void setOrientation​(int orientation)
        Deprecated.
        Sets the orientation hint for the video playback.
        Parameters:
        orientation - The orientation, in degrees.
      • setLocation

        public void setLocation​(@FloatRange(from=-90.0,to=90.0)
                                float latitude,
                                @FloatRange(from=-180.0,to=180.0)
                                float longitude)
        Deprecated.
        Sets the location.
        Parameters:
        latitude - The latitude, in degrees. Its value must be in the range [-90, 90].
        longitude - The longitude, in degrees. Its value must be in the range [-180, 180].
      • setCaptureFps

        public void setCaptureFps​(float captureFps)
        Deprecated.
        Sets the capture frame rate.
        Parameters:
        captureFps - The frame rate.
      • setModificationTime

        public void setModificationTime​(long timestampMs)
        Deprecated.
        Sets the file modification time.
        Parameters:
        timestampMs - The modification time UTC in milliseconds since the Unix epoch.
      • addMetadata

        public void addMetadata​(String key,
                                Object value)
        Deprecated.
        Adds custom metadata.
        Parameters:
        key - The metadata key in String format.
        value - The metadata value in String or Float format.
      • addXmp

        public void addXmp​(ByteBuffer xmp)
        Deprecated.
        Adds xmp data.
        Parameters:
        xmp - The xmp ByteBuffer.