@UnstableApi
public final class FrameworkMuxer implements Muxer


Muxer implementation that uses a MediaMuxer.

Summary

Nested types

public final class FrameworkMuxer.Factory implements Muxer.Factory

Muxer.Factory for FrameworkMuxer.

Constants

static final String
static final String
MUXER_STOPPING_FAILED_ERROR_MESSAGE = "Failed to stop the MediaMuxer"

Public methods

void

Adds metadata about the output file.

int
addTrack(Format format)

Adds a track of the given media format.

void

Closes the file.

void
writeSampleData(int trackId, ByteBuffer data, BufferInfo bufferInfo)

Writes encoded sample data.

Inherited methods

From java.lang.AutoCloseable
abstract void

Constants

MUXER_NAME

public static final String MUXER_NAME

MUXER_STOPPING_FAILED_ERROR_MESSAGE

public static final String MUXER_STOPPING_FAILED_ERROR_MESSAGE = "Failed to stop the MediaMuxer"

Public methods

addMetadataEntry

public void addMetadataEntry(Metadata.Entry metadataEntry)

Adds metadata about the output file.

addTrack

public int addTrack(Format format)

Adds a track of the given media format.

All tracks must be added before any samples are written to any track.

Parameters
Format format

The Format of the track.

Returns
int

A track id for this track, which should be passed to writeSampleData.

Throws
androidx.media3.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.MuxerException

If the muxer fails to finish writing the output.

writeSampleData

public void writeSampleData(int trackId, ByteBuffer data, BufferInfo bufferInfo)

Writes encoded sample data.

Parameters
int trackId

The track id, previously returned by addTrack.

ByteBuffer data

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

BufferInfo bufferInfo

The BufferInfo of the sample.