# FrameworkMuxer

Artifact: [androidx.media3:media3-transformer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/transformer/FrameworkMuxer.java+class:androidx.media3.transformer.FrameworkMuxer)

*** ** * ** ***


```
@UnstableApi
public final class FrameworkMuxer implements Muxer
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/media3/muxer/Muxer` implementation that uses a `https://developer.android.com/reference/android/media/MediaMuxer.html`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer.Factory implements https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory` `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory` for `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer`. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer#MUXER_NAME()` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer#MUXER_STOPPING_FAILED_ERROR_MESSAGE() = "Failed to stop the MediaMuxer"` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer#addMetadataEntry(androidx.media3.common.Metadata.Entry)(https://developer.android.com/reference/androidx/media3/common/Metadata.Entry metadataEntry)` Adds `https://developer.android.com/reference/androidx/media3/common/Metadata.Entry` about the output file. |
| `int` | `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer#addTrack(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Adds a track of the given media format. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer#close()()` Closes the file. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer#writeSampleData(int,java.nio.ByteBuffer,androidx.media3.muxer.BufferInfo)(int trackId, https://developer.android.com/reference/java/nio/ByteBuffer.html data, https://developer.android.com/reference/androidx/media3/muxer/BufferInfo bufferInfo)` Writes encoded sample data. |

| ### Inherited methods |
|---|
| From [java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable.html) |---|---| | `abstract void` | `https://developer.android.com/reference/java/lang/AutoCloseable.html#close()()` | |

## 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 `https://developer.android.com/reference/androidx/media3/common/Metadata.Entry` 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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` of the track. |

| Returns |
|---|---|
| `int` | A track id for this track, which should be passed to `https://developer.android.com/reference/androidx/media3/muxer/Muxer#writeSampleData(int,java.nio.ByteBuffer,androidx.media3.muxer.BufferInfo)`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/media3/transformer/FrameworkMuxer#addTrack(androidx.media3.common.Format)`. |
| `https://developer.android.com/reference/java/nio/ByteBuffer.html data` | A buffer containing the sample data to write to the container. |
| `https://developer.android.com/reference/androidx/media3/muxer/BufferInfo bufferInfo` | The `https://developer.android.com/reference/androidx/media3/muxer/BufferInfo` of the sample. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/MuxerException` |   |