@UnstableApi
class FrameworkMuxer : Muxer


Muxer implementation that uses a MediaMuxer.

Summary

Constants

const String!
const String!
MUXER_STOPPING_FAILED_ERROR_MESSAGE = "Failed to stop the MediaMuxer"

Public functions

Unit

Adds metadata about the output file.

Int
addTrack(format: Format!)

Adds a track of the given media format.

Unit

Closes the file.

Unit
writeSampleData(trackId: Int, data: ByteBuffer!, bufferInfo: BufferInfo!)

Writes encoded sample data.

Inherited functions

From java.lang.AutoCloseable
abstract Unit

Constants

MUXER_NAME

const val MUXER_NAMEString!

MUXER_STOPPING_FAILED_ERROR_MESSAGE

const val MUXER_STOPPING_FAILED_ERROR_MESSAGE = "Failed to stop the MediaMuxer": String!

Public functions

addMetadataEntry

fun addMetadataEntry(metadataEntry: Metadata.Entry!): Unit

Adds metadata about the output file.

addTrack

fun addTrack(format: Format!): Int

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

fun close(): Unit

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

fun writeSampleData(trackId: Int, data: ByteBuffer!, bufferInfo: BufferInfo!): Unit

Writes encoded sample data.

Parameters
trackId: Int

The track id, previously returned by addTrack.

data: ByteBuffer!

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

bufferInfo: BufferInfo!

The BufferInfo of the sample.