# InAppMp4Muxer.Factory

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.Factory)

*** ** * ** ***


```
public final class InAppMp4Muxer.Factory implements Muxer.Factory
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory` for `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#Factory()()` Creates an instance with default values. |
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#Factory(androidx.media3.transformer.InAppMp4Muxer.MetadataProvider)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.MetadataProvider metadataProvider)` Creates an instance. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer` | `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#create(java.lang.String)(https://developer.android.com/reference/java/lang/String.html path)` Returns a new `https://developer.android.com/reference/androidx/media3/muxer/Muxer`. |
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer` | `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#create(android.os.ParcelFileDescriptor)(https://developer.android.com/reference/android/os/ParcelFileDescriptor.html pfd)` Returns a new `https://developer.android.com/reference/androidx/media3/muxer/Muxer`. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#getSupportedSampleMimeTypes(int)(@https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType)` Returns the supported sample `https://developer.android.com/reference/androidx/media3/common/MimeTypes` for the given `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#setAttemptStreamableOutputEnabled(boolean)( boolean attemptStreamableOutputEnabled )` Sets whether to attempt to write a file where the metadata is stored at the start, which can make the file more efficient to read sequentially. |
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#setFreeSpaceAfterFileTypeBoxBytes(int)(int freeSpaceAfterFileTypeBoxBytes)` Sets the amount of free space (in bytes) to be reserved after the File Type box in the MP4 file. |
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#setVideoDurationUs(long)(long videoDurationUs)` Sets the duration of the video track (in microseconds) in the output. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory#supportsWritingNegativeTimestampsInEditList()()` Whether the muxer supports writing negative timestamps into an edit list to instruct players to ignore these samples. |

## Public constructors

### Factory

```
public Factory()
```

Creates an instance with default values.

### Factory

```
public Factory(@Nullable InAppMp4Muxer.MetadataProvider metadataProvider)
```

Creates an instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.MetadataProvider metadataProvider` | A `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.MetadataProvider`. |

## Public methods

### create

```
public InAppMp4Muxer create(String path)
```

Returns a new `https://developer.android.com/reference/androidx/media3/muxer/Muxer`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html path` | The path to the output file. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/MuxerException` | If an error occurs opening the output file for writing. |

### create

```
public InAppMp4Muxer create(ParcelFileDescriptor pfd)
```

Returns a new `https://developer.android.com/reference/androidx/media3/muxer/Muxer`.

The caller transfers ownership of the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` to the `https://developer.android.com/reference/androidx/media3/muxer/Muxer.Factory`. If this method returns successfully, the created `https://developer.android.com/reference/androidx/media3/muxer/Muxer` is responsible for closing the descriptor when `https://developer.android.com/reference/androidx/media3/muxer/Muxer#close()` is called. If an error occurs and a `https://developer.android.com/reference/androidx/media3/muxer/MuxerException` is thrown, the descriptor is closed before the exception is thrown.

Whether the provided `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` must be seekable depends on the container format and `https://developer.android.com/reference/androidx/media3/muxer/Muxer` implementation. For example, standard MP4 muxers require seekable descriptors (such as those opened with `"rwt"` or `"rw"`), whereas streaming muxers (such as fragmented MP4 muxers) also accept non-seekable streams like pipes.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html pfd` | the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` to write output to |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/muxer/MuxerException` | if an error occurs opening the output for writing or if the descriptor does not satisfy the seekability requirements of the muxer |

### getSupportedSampleMimeTypes

```
public ImmutableList<String> getSupportedSampleMimeTypes(@C.TrackType int trackType)
```

Returns the supported sample `https://developer.android.com/reference/androidx/media3/common/MimeTypes` for the given `https://developer.android.com/reference/androidx/media3/common/C.TrackType`.

### setAttemptStreamableOutputEnabled

```
@CanIgnoreReturnValue
public InAppMp4Muxer.Factory setAttemptStreamableOutputEnabled(
    boolean attemptStreamableOutputEnabled
)
```

Sets whether to attempt to write a file where the metadata is stored at the start, which can make the file more efficient to read sequentially.

Setting to `true` does not guarantee a streamable MP4 output.

Setting to `true` reserves space at the start of the file which leads to increased file size. Set this to `false` for smaller file size.

The default value is `true`.

| Parameters |
|---|---|
| `boolean attemptStreamableOutputEnabled` | Whether to attempt to write a streamable file. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory` | This factory. |

### setFreeSpaceAfterFileTypeBoxBytes

```
@CanIgnoreReturnValue
public InAppMp4Muxer.Factory setFreeSpaceAfterFileTypeBoxBytes(int freeSpaceAfterFileTypeBoxBytes)
```

Sets the amount of free space (in bytes) to be reserved after the File Type box in the MP4 file. The amount of free space that gets reserved is handled by `https://developer.android.com/reference/androidx/media3/muxer/Mp4Muxer.Builder#experimentalSetFreeSpaceAfterFileTypeBox(int)`.

| Parameters |
|---|---|
| `int freeSpaceAfterFileTypeBoxBytes` | The free space after file type box in the output. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory` | This factory. |

### setVideoDurationUs

```
@CanIgnoreReturnValue
public InAppMp4Muxer.Factory setVideoDurationUs(long videoDurationUs)
```

Sets the duration of the video track (in microseconds) in the output.

Only the duration of the last sample is adjusted to achieve the given duration. Duration of the other samples remains unchanged.

The default is `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to not set any duration in the output. In this case the video track duration is determined by the samples written to it and the duration of the last sample will be same as that of the sample before that.

| Parameters |
|---|---|
| `long videoDurationUs` | The duration of the video track (in microseconds) in the output, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to not set any duration. Only applicable when a video track is `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer#addTrack(androidx.media3.common.Format)`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/InAppMp4Muxer.Factory` | This factory. |

### supportsWritingNegativeTimestampsInEditList

```
public boolean supportsWritingNegativeTimestampsInEditList()
```

Whether the muxer supports writing negative timestamps into an edit list to instruct players to ignore these samples.