# DefaultEncoderFactory

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

*** ** * ** ***


```
@UnstableApi
public final class DefaultEncoderFactory implements Codec.EncoderFactory
```

<br />

*** ** * ** ***

A default implementation of `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory.Builder` A builder for `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory` instances. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory#audioNeedsEncoding()()` Returns whether the audio needs to be encoded because of encoder specific configuration. |
| `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory.Builder` | `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory#buildUpon()()` Returns a `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory.Builder` initialized with the values of this instance. |
| `https://developer.android.com/reference/androidx/media3/transformer/DefaultCodec` | `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory#createForAudioEncoding(androidx.media3.common.Format,android.media.metrics.LogSessionId)( https://developer.android.com/reference/androidx/media3/common/Format format, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/media/metrics/LogSessionId.html logSessionId )` Returns a `https://developer.android.com/reference/androidx/media3/transformer/Codec` for audio encoding. |
| `https://developer.android.com/reference/androidx/media3/transformer/DefaultCodec` | `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory#createForVideoEncoding(androidx.media3.common.Format,android.media.metrics.LogSessionId)( https://developer.android.com/reference/androidx/media3/common/Format format, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/media/metrics/LogSessionId.html logSessionId )` Returns a `https://developer.android.com/reference/androidx/media3/transformer/DefaultCodec` for video encoding. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory#isVideoFormatSupported(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format requestedFormat)` Returns whether the requested video `https://developer.android.com/reference/androidx/media3/common/Format` is supported by the encoder factory. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory#videoNeedsEncoding()()` Returns whether the video needs to be encoded because of encoder specific configuration. |

## Public methods

### audioNeedsEncoding

```
public boolean audioNeedsEncoding()
```

Returns whether the audio needs to be encoded because of encoder specific configuration.

### buildUpon

```
public DefaultEncoderFactory.Builder buildUpon()
```

Returns a `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory.Builder` initialized with the values of this instance.

### createForAudioEncoding

```
public DefaultCodec createForAudioEncoding(
    Format format,
    @Nullable LogSessionId logSessionId
)
```

Returns a `https://developer.android.com/reference/androidx/media3/transformer/Codec` for audio encoding.

The caller should ensure the `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()` is supported on the device before calling this method.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` (of the output data) used to determine the underlying encoder and its configuration values. `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()`, `https://developer.android.com/reference/androidx/media3/common/Format#sampleRate()`, `https://developer.android.com/reference/androidx/media3/common/Format#channelCount()` and `https://developer.android.com/reference/androidx/media3/common/Format#bitrate()` are set to those of the desired output video format. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/media/metrics/LogSessionId.html logSessionId` | The optional `https://developer.android.com/reference/android/media/metrics/LogSessionId.html` of the `https://developer.android.com/reference/android/media/metrics/EditingSession.html`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/DefaultCodec` | A `https://developer.android.com/reference/androidx/media3/transformer/Codec` for encoding audio to the requested `https://developer.android.com/reference/androidx/media3/common/Format#sampleMimeType()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/ExportException` | If no suitable `https://developer.android.com/reference/androidx/media3/transformer/Codec` can be created. |

### createForVideoEncoding

```
public DefaultCodec createForVideoEncoding(
    Format format,
    @Nullable LogSessionId logSessionId
)
```

Returns a `https://developer.android.com/reference/androidx/media3/transformer/DefaultCodec` for video encoding.

Use `https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory.Builder#setRequestedVideoEncoderSettings(androidx.media3.transformer.VideoEncoderSettings)` with `https://developer.android.com/reference/androidx/media3/transformer/VideoEncoderSettings#bitrate()` set to request for a specific encoding bitrate. Bitrate settings in `https://developer.android.com/reference/androidx/media3/common/Format` are ignored when `https://developer.android.com/reference/androidx/media3/transformer/VideoEncoderSettings#bitrate()` is set.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/transformer/ExportException` |   |

### isVideoFormatSupported

```
public boolean isVideoFormatSupported(Format requestedFormat)
```

Returns whether the requested video `https://developer.android.com/reference/androidx/media3/common/Format` is supported by the encoder factory.

This is an experimental API and is currently being used for `FrameWriter` specifically.

### videoNeedsEncoding

```
public boolean videoNeedsEncoding()
```

Returns whether the video needs to be encoded because of encoder specific configuration.