@UnstableApi
class AacMuxer : Muxer


A muxer for creating an AAC (Advanced Audio Coding) container file.

This muxer supports muxing of AAC audio codec.

Summary

Public constructors

AacMuxer(outputStream: FileOutputStream!)

Creates an AacMuxer instance.

Public functions

Unit

Adds metadata about the output file.

Int
addTrack(format: Format!)

Add an AAC audio track.

Unit

Closes the file.

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

Writes encoded sample data.

Inherited functions

From java.lang.AutoCloseable
abstract Unit

Public constructors

AacMuxer

AacMuxer(outputStream: FileOutputStream!)

Creates an AacMuxer instance.

Parameters
outputStream: FileOutputStream!

The FileOutputStream where the output will be written.

Public functions

addMetadataEntry

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

Adds metadata about the output file.

This operation is not supported for AAC muxing and will always throw an .

addTrack

fun addTrack(format: Format!): Int

Add an AAC audio track.

Parameters
format: Format!

The Format of the track.

Returns
Int

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

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,
    byteBuffer: ByteBuffer!,
    bufferInfo: BufferInfo!
): Unit

Writes encoded sample data.

Parameters
trackId: Int

The track id, previously returned by addTrack.

byteBuffer: ByteBuffer!

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

bufferInfo: BufferInfo!

The BufferInfo of the sample.

Throws
androidx.media3.muxer.MuxerException

If the muxer fails to write the sample.