# Codec.EncoderFactory

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

*** ** * ** ***


```
public interface Codec.EncoderFactory
```

<br />

Known direct subclasses [DefaultEncoderFactory](https://developer.android.com/reference/androidx/media3/transformer/DefaultEncoderFactory)

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

*** ** * ** ***

A factory for `https://developer.android.com/reference/androidx/media3/transformer/Codec` instances.

## Summary

| ### Public methods |
|---|---|
| `default boolean` | `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory#audioNeedsEncoding()()` Returns whether the audio needs to be encoded because of encoder specific configuration. |
| `abstract https://developer.android.com/reference/androidx/media3/transformer/Codec` | `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory#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. |
| `abstract https://developer.android.com/reference/androidx/media3/transformer/Codec` | `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory#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/Codec` for video encoding. |
| `default boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory#isVideoFormatSupported(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Returns whether the requested video `https://developer.android.com/reference/androidx/media3/common/Format` is supported by the encoder factory. |
| `default boolean` | `https://developer.android.com/reference/androidx/media3/transformer/Codec.EncoderFactory#videoNeedsEncoding()()` Returns whether the video needs to be encoded because of encoder specific configuration. |

## Public methods

### audioNeedsEncoding

```
default boolean audioNeedsEncoding()
```

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

### createForAudioEncoding

```
abstract Codec 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/Codec` | 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

```
abstract Codec createForVideoEncoding(
    Format format,
    @Nullable LogSessionId logSessionId
)
```

Returns a `https://developer.android.com/reference/androidx/media3/transformer/Codec` for video 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. If encoding to HDR, the caller should also ensure the `https://developer.android.com/reference/androidx/media3/common/Format#colorInfo()` are supported.

| 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#width()` and `https://developer.android.com/reference/androidx/media3/common/Format#height()` are set to those of the desired output video format. `https://developer.android.com/reference/androidx/media3/common/Format#frameRate()` is set to the requested output frame rate, if available. `https://developer.android.com/reference/androidx/media3/common/Format#colorInfo()` is set to the requested output color characteristics, if available. `https://developer.android.com/reference/androidx/media3/common/Format#rotationDegrees()` is always 0. |
| `@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/Codec` | A `https://developer.android.com/reference/androidx/media3/transformer/Codec` for encoding video 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. |

### isVideoFormatSupported

```
@ExperimentalApi
default boolean isVideoFormatSupported(Format format)
```

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

```
default boolean videoNeedsEncoding()
```

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