# InAppMp4Muxer

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/InAppMp4Muxer.java+class:androidx.media3.transformer.InAppMp4Muxer)

*** ** * ** ***


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

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/media3/muxer/Muxer` implementation that uses an `https://developer.android.com/reference/androidx/media3/muxer/Mp4Muxer`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.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/InAppMp4Muxer`. |
| `public interface https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.MetadataProvider` Provides `https://developer.android.com/reference/androidx/media3/common/Metadata.Entry` to add in the output MP4 file. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer#MUXER_NAME() = "androidx.media3:media3-muxer:1.12.0-alpha02"` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer#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/InAppMp4Muxer#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/InAppMp4Muxer#close()()` Closes the file. |
| `void` | `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer#writeSampleData(int,java.nio.ByteBuffer,androidx.media3.muxer.BufferInfo)( int trackId, https://developer.android.com/reference/java/nio/ByteBuffer.html byteBuffer, 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 = "androidx.media3:media3-muxer:1.12.0-alpha02"
```

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

Writes encoded sample data.

| Parameters |
|---|---|
| `int trackId` | The track id, previously returned by `https://developer.android.com/reference/androidx/media3/muxer/Muxer#addTrack(androidx.media3.common.Format)`. |
| `https://developer.android.com/reference/java/nio/ByteBuffer.html byteBuffer` | 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` | If the muxer fails to write the sample. |