# 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
class DefaultEncoderFactory : Codec.EncoderFactory
```

<br />

*** ** * ** ***

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

## Summary

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

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

## Public functions

### audioNeedsEncoding

```
fun audioNeedsEncoding(): Boolean
```

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

### buildUpon

```
fun buildUpon(): DefaultEncoderFactory.Builder!
```

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

### createForAudioEncoding

```
fun createForAudioEncoding(format: Format!, logSessionId: LogSessionId?): DefaultCodec!
```

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

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

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` (of the output data) used to determine the underlying encoder and its configuration values. `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#sampleMimeType()`, `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#sampleRate()`, `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#channelCount()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#bitrate()` are set to those of the desired output video format. |
| `logSessionId: https://developer.android.com/reference/android/media/metrics/LogSessionId.html?` | 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/kotlin/androidx/media3/transformer/DefaultCodec!` | A `https://developer.android.com/reference/kotlin/androidx/media3/transformer/Codec` for encoding audio to the requested `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#sampleMimeType()`. |

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

### createForVideoEncoding

```
fun createForVideoEncoding(format: Format!, logSessionId: LogSessionId?): DefaultCodec!
```

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

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

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

### isVideoFormatSupported

```
fun isVideoFormatSupported(requestedFormat: Format!): Boolean
```

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

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

### videoNeedsEncoding

```
fun videoNeedsEncoding(): Boolean
```

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