Skip to content

Most visited

Recently visited

navigation
Added in API level 16

MediaCodecList

public final class MediaCodecList
extends Object

java.lang.Object
   ↳ android.media.MediaCodecList


Allows you to enumerate available codecs, each specified as a MediaCodecInfo object, find a codec supporting a given format and query the capabilities of a given codec.

See MediaCodecInfo for sample usage.

Summary

Constants

int ALL_CODECS

Use in MediaCodecList(int) to enumerate all codecs, even ones that are not suitable for regular (buffer-to-buffer) decoding or encoding.

int REGULAR_CODECS

Use in MediaCodecList(int) to enumerate only codecs that are suitable for regular (buffer-to-buffer) decoding or encoding.

Public constructors

MediaCodecList(int kind)

Create a list of media-codecs of a specific kind.

Public methods

final String findDecoderForFormat(MediaFormat format)

Find a decoder supporting a given MediaFormat in the list of media-codecs.

final String findEncoderForFormat(MediaFormat format)

Find an encoder supporting a given MediaFormat in the list of media-codecs.

final static int getCodecCount()

This method was deprecated in API level 21. Use getCodecInfos() instead.

final static MediaCodecInfo getCodecInfoAt(int index)

This method was deprecated in API level 21. Use getCodecInfos() instead.

final MediaCodecInfo[] getCodecInfos()

Returns the list of MediaCodecInfo objects for the list of media-codecs.

Inherited methods

From class java.lang.Object

Constants

ALL_CODECS

Added in API level 21
int ALL_CODECS

Use in MediaCodecList(int) to enumerate all codecs, even ones that are not suitable for regular (buffer-to-buffer) decoding or encoding. These include codecs, for example, that only work with special input or output surfaces, such as secure-only or tunneled-only codecs.

See also:

Constant Value: 1 (0x00000001)

REGULAR_CODECS

Added in API level 21
int REGULAR_CODECS

Use in MediaCodecList(int) to enumerate only codecs that are suitable for regular (buffer-to-buffer) decoding or encoding. NOTE: These are the codecs that are returned prior to API 21, using the now deprecated static methods.

Constant Value: 0 (0x00000000)

Public constructors

MediaCodecList

Added in API level 21
MediaCodecList (int kind)

Create a list of media-codecs of a specific kind.

Parameters
kind int: Either REGULAR_CODECS or ALL_CODECS.

Public methods

findDecoderForFormat

Added in API level 21
String findDecoderForFormat (MediaFormat format)

Find a decoder supporting a given MediaFormat in the list of media-codecs.

Note: On LOLLIPOP, format must not contain a frame rate. Use format.setString(MediaFormat.KEY_FRAME_RATE, null) to clear any existing frame rate setting in the format.

Parameters
format MediaFormat: A decoder media format with optional feature directives.
Returns
String the name of a decoder that supports the given format and feature requests, or null if no such codec has been found.
Throws
IllegalArgumentException if format is not a valid media format.
NullPointerException if format is null.

findEncoderForFormat

Added in API level 21
String findEncoderForFormat (MediaFormat format)

Find an encoder supporting a given MediaFormat in the list of media-codecs.

Note: On LOLLIPOP, format must not contain a frame rate. Use format.setString(MediaFormat.KEY_FRAME_RATE, null) to clear any existing frame rate setting in the format.

Parameters
format MediaFormat: An encoder media format with optional feature directives.
Returns
String the name of an encoder that supports the given format and feature requests, or null if no such codec has been found.
Throws
IllegalArgumentException if format is not a valid media format.
NullPointerException if format is null.

getCodecCount

Added in API level 16
int getCodecCount ()

This method was deprecated in API level 21.
Use getCodecInfos() instead.

Count the number of available (regular) codecs.

Returns
int

See also:

getCodecInfoAt

Added in API level 16
MediaCodecInfo getCodecInfoAt (int index)

This method was deprecated in API level 21.
Use getCodecInfos() instead.

Return the MediaCodecInfo object for the codec at the given index in the regular list.

Parameters
index int
Returns
MediaCodecInfo

See also:

getCodecInfos

Added in API level 21
MediaCodecInfo[] getCodecInfos ()

Returns the list of MediaCodecInfo objects for the list of media-codecs.

Returns
MediaCodecInfo[]
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.