EncoderFinder

@RequiresApi(value = 21) public class EncoderFinder


Workaround to find the suitable encoder.

The workaround is to check the quirks to fix the selection of video encoder.

Summary

Public constructors

Public methods

@NonNull MediaCodec
findEncoder(
    @NonNull MediaFormat mediaFormat,
    @NonNull MediaCodecList mediaCodecList
)

Selects an encoder by a given MediaFormat.

Public constructors

EncoderFinder

public EncoderFinder()

Public methods

findEncoder

@NonNull
public MediaCodec findEncoder(
    @NonNull MediaFormat mediaFormat,
    @NonNull MediaCodecList mediaCodecList
)

Selects an encoder by a given MediaFormat.

The encoder finder might temporarily alter the media format for better compatibility based on OS version. It is not thread safe to use the same media format instance.

Parameters
@NonNull MediaFormat mediaFormat

the media format used to find the encoder.

Returns
MediaCodec

the MediaCodec suitable for the given media format.

Throws
androidx.camera.video.internal.encoder.InvalidConfigException

if it is not able to find a MediaCodec by the given media format.