@UnstableApi
public final class InAppMuxer implements Muxer


Muxer implementation that uses an Mp4Muxer or FragmentedMp4Muxer.

Summary

Nested types

public final class InAppMuxer.Factory implements Muxer.Factory

Muxer.Factory for InAppMuxer.

public final class InAppMuxer.Factory.Builder

A builder for Factory instances.

Provides metadata to add in the output MP4 file.

Public methods

void

Adds metadata about the output file.

Muxer.TrackToken
addTrack(Format format)

Adds a track of the given media format.

void

Closes the file.

void
writeSampleData(
    Muxer.TrackToken trackToken,
    ByteBuffer byteBuffer,
    MediaCodec.BufferInfo bufferInfo
)

Writes encoded sample data.

Public methods

addMetadataEntry

public void addMetadataEntry(Metadata.Entry metadataEntry)

Adds metadata about the output file.

addTrack

public Muxer.TrackToken addTrack(Format format)

Adds a track of the given media format.

Parameters
Format format

The Format of the track.

Returns
Muxer.TrackToken

The TrackToken for this track, which should be passed to writeSampleData.

Throws
androidx.media3.muxer.Muxer.MuxerException

If the muxer encounters a problem while adding the track.

close

public void close()

Closes the file.

The muxer cannot be used anymore once this method returns.

Throws
androidx.media3.muxer.Muxer.MuxerException

If the muxer fails to finish writing the output.

writeSampleData

public void writeSampleData(
    Muxer.TrackToken trackToken,
    ByteBuffer byteBuffer,
    MediaCodec.BufferInfo bufferInfo
)

Writes encoded sample data.

Parameters
Muxer.TrackToken trackToken

The TrackToken of the track, previously returned by addTrack.

ByteBuffer byteBuffer

A buffer containing the sample data to write to the container.

MediaCodec.BufferInfo bufferInfo

The BufferInfo of the sample.

Throws
androidx.media3.muxer.Muxer.MuxerException

If the muxer fails to write the sample.