@UnstableApi
public final class WebmMuxer implements Muxer


A muxer for creating a WebM container file.

Muxer supports muxing of:

  • Video Codecs:
    • VP8
    • VP9
  • Audio Codecs:
    • Opus
    • Vorbis

Summary

Nested types

public final class WebmMuxer.Builder

A builder for WebmMuxer instances.

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 byteBuffer,
    BufferInfo bufferInfo
)

Writes encoded sample data.

Inherited methods

From java.lang.AutoCloseable
abstract void

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 byteBuffer,
    BufferInfo bufferInfo
)

Writes encoded sample data.

Parameters
int trackId

The track id for which this sample is being written.

ByteBuffer byteBuffer

The encoded sample. The muxer takes ownership of the buffer if sample copying is disabled. Otherwise, the position of the buffer is updated but the caller retains ownership.

BufferInfo bufferInfo

The BufferInfo related to this sample.

Throws
androidx.media3.muxer.MuxerException

If an error occurs while writing data to the output file.