Android APIs
public final class

MediaFormat

extends Object
java.lang.Object
   ↳ android.media.MediaFormat

Class Overview

Encapsulates the information describing the format of media data, be it audio or video. The format of the media data is specified as string/value pairs. Keys common to all audio/video formats, all keys not marked optional are mandatory:

NameValue TypeDescription
KEY_MIMEStringThe type of the format.
KEY_MAX_INPUT_SIZEIntegeroptional, maximum size of a buffer of input data
KEY_BIT_RATEIntegerencoder-only, desired bitrate in bits/second
Video formats have the following keys:
NameValue TypeDescription
KEY_WIDTHInteger
KEY_HEIGHTInteger
KEY_COLOR_FORMATIntegerset by the user for encoders, readable in the output format of decoders
KEY_FRAME_RATEInteger or Floatencoder-only
KEY_CAPTURE_RATEInteger
KEY_I_FRAME_INTERVALIntegerencoder-only
KEY_MAX_WIDTHIntegerdecoder-only, optional, max-resolution width
KEY_MAX_HEIGHTIntegerdecoder-only, optional, max-resolution height
KEY_REPEAT_PREVIOUS_FRAME_AFTERLongvideo encoder in surface-mode only
KEY_PUSH_BLANK_BUFFERS_ON_STOPInteger(1)video decoder rendering to a surface only
Specify both KEY_MAX_WIDTH and KEY_MAX_HEIGHT to enable adaptive playback (seamless resolution change) for a video decoder that supports it (FEATURE_AdaptivePlayback). The values are used as hints for the codec: they are the maximum expected resolution to prepare for. Depending on codec support, preparing for larger maximum resolution may require more memory even if that resolution is never reached. These fields have no effect for codecs that do not support adaptive playback.

Audio formats have the following keys:
NameValue TypeDescription
KEY_CHANNEL_COUNTInteger
KEY_SAMPLE_RATEInteger
KEY_IS_ADTSIntegeroptional, if decoding AAC audio content, setting this key to 1 indicates that each audio frame is prefixed by the ADTS header.
KEY_AAC_PROFILEIntegerencoder-only, optional, if content is AAC audio, specifies the desired profile.
KEY_AAC_SBR_MODEIntegerencoder-only, optional, if content is AAC audio, specifies the desired SBR mode.
KEY_AAC_DRC_TARGET_REFERENCE_LEVELIntegerdecoder-only, optional, if content is AAC audio, specifies the target reference level.
KEY_AAC_ENCODED_TARGET_LEVELIntegerdecoder-only, optional, if content is AAC audio, specifies the target reference level used at encoder.
KEY_AAC_DRC_BOOST_FACTORIntegerdecoder-only, optional, if content is AAC audio, specifies the DRC boost factor.
KEY_AAC_DRC_ATTENUATION_FACTORIntegerdecoder-only, optional, if content is AAC audio, specifies the DRC attenuation factor.
KEY_AAC_DRC_HEAVY_COMPRESSIONIntegerdecoder-only, optional, if content is AAC audio, specifies whether to use heavy compression.
KEY_AAC_MAX_OUTPUT_CHANNEL_COUNTIntegerdecoder-only, optional, if content is AAC audio, specifies the maximum number of channels the decoder outputs.
KEY_CHANNEL_MASKIntegeroptional, a mask of audio channel assignments
KEY_FLAC_COMPRESSION_LEVELIntegerencoder-only, optional, if content is FLAC audio, specifies the desired compression level.
Subtitle formats have the following keys:
KEY_MIMEStringThe type of the format.
KEY_LANGUAGEStringThe language of the content.

Summary

Constants
String KEY_AAC_DRC_ATTENUATION_FACTOR A key describing the attenuation factor allowing to adapt the dynamics of the output to the actual listening requirements.
String KEY_AAC_DRC_BOOST_FACTOR A key describing the boost factor allowing to adapt the dynamics of the output to the actual listening requirements.
String KEY_AAC_DRC_HEAVY_COMPRESSION A key describing the selection of the heavy compression profile for DRC.
String KEY_AAC_DRC_TARGET_REFERENCE_LEVEL A key describing a gain to be applied so that the output loudness matches the Target Reference Level.
String KEY_AAC_ENCODED_TARGET_LEVEL A key describing the target reference level that was assumed at the encoder for calculation of attenuation gains for clipping prevention.
String KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT A key describing the maximum number of channels that can be output by the AAC decoder.
String KEY_AAC_PROFILE A key describing the AAC profile to be used (AAC audio formats only).
String KEY_AAC_SBR_MODE A key describing the AAC SBR mode to be used (AAC audio formats only).
String KEY_AUDIO_SESSION_ID A key describing the audio session ID of the AudioTrack associated to a tunneled video codec.
String KEY_BITRATE_MODE A key describing the desired bitrate mode to be used by an encoder.
String KEY_BIT_RATE A key describing the bitrate in bits/sec.
String KEY_CAPTURE_RATE A key describing the capture rate of a video format in frames/sec.
String KEY_CHANNEL_COUNT A key describing the number of channels in an audio format.
String KEY_CHANNEL_MASK A key describing the channel composition of audio content.
String KEY_COLOR_FORMAT A key describing the color format of the content in a video format.
String KEY_COMPLEXITY A key describing the encoding complexity.
String KEY_DURATION A key describing the duration (in microseconds) of the content.
String KEY_FLAC_COMPRESSION_LEVEL A key describing the FLAC compression level to be used (FLAC audio format only).
String KEY_FRAME_RATE A key describing the frame rate of a video format in frames/sec.
String KEY_HEIGHT A key describing the height of the content in a video format.
String KEY_IS_ADTS A key mapping to a value of 1 if the content is AAC audio and audio frames are prefixed with an ADTS header.
String KEY_IS_AUTOSELECT A key for boolean AUTOSELECT behavior for the track.
String KEY_IS_DEFAULT A key for boolean DEFAULT behavior for the track.
String KEY_IS_FORCED_SUBTITLE A key for the FORCED field for subtitle tracks.
String KEY_I_FRAME_INTERVAL A key describing the frequency of I frames expressed in secs between I frames.
String KEY_LANGUAGE A key describing the language of the content, using either ISO 639-1 or 639-2/T codes.
String KEY_LEVEL A key describing the desired profile to be used by an encoder.
String KEY_MAX_HEIGHT A key describing the maximum expected height of the content in a video decoder format, in case there are resolution changes in the video content.
String KEY_MAX_INPUT_SIZE A key describing the maximum size in bytes of a buffer of data described by this MediaFormat.
String KEY_MAX_WIDTH A key describing the maximum expected width of the content in a video decoder format, in case there are resolution changes in the video content.
String KEY_MIME A key describing the mime type of the MediaFormat.
String KEY_OPERATING_RATE A key describing the desired operating frame rate for video or sample rate for audio that the codec will need to operate at.
String KEY_PRIORITY A key describing the desired codec priority.
String KEY_PROFILE A key describing the desired profile to be used by an encoder.
String KEY_PUSH_BLANK_BUFFERS_ON_STOP If specified when configuring a video decoder rendering to a surface, causes the decoder to output "blank", i.e.
String KEY_REPEAT_PREVIOUS_FRAME_AFTER Applies only when configuring a video encoder in "surface-input" mode.
String KEY_ROTATION A key describing the desired clockwise rotation on an output surface.
String KEY_SAMPLE_RATE A key describing the sample rate of an audio format.
String KEY_SLICE_HEIGHT A key describing the plane height of a multi-planar (YUV) video bytebuffer layout.
String KEY_STRIDE A key describing the stride of the video bytebuffer layout.
String KEY_TEMPORAL_LAYERING A key describing the temporal layering schema.
String KEY_WIDTH A key describing the width of the content in a video format.
String MIMETYPE_AUDIO_AAC
String MIMETYPE_AUDIO_AC3
String MIMETYPE_AUDIO_AMR_NB
String MIMETYPE_AUDIO_AMR_WB
String MIMETYPE_AUDIO_EAC3
String MIMETYPE_AUDIO_FLAC
String MIMETYPE_AUDIO_G711_ALAW
String MIMETYPE_AUDIO_G711_MLAW
String MIMETYPE_AUDIO_MPEG
String MIMETYPE_AUDIO_MSGSM
String MIMETYPE_AUDIO_OPUS
String MIMETYPE_AUDIO_QCELP
String MIMETYPE_AUDIO_RAW
String MIMETYPE_AUDIO_VORBIS
String MIMETYPE_TEXT_CEA_608 MIME type for CEA-608 closed caption data.
String MIMETYPE_TEXT_VTT MIME type for WebVTT subtitle data.
String MIMETYPE_VIDEO_AVC
String MIMETYPE_VIDEO_H263
String MIMETYPE_VIDEO_HEVC
String MIMETYPE_VIDEO_MPEG2
String MIMETYPE_VIDEO_MPEG4
String MIMETYPE_VIDEO_RAW
String MIMETYPE_VIDEO_VP8
String MIMETYPE_VIDEO_VP9
Public Constructors
MediaFormat()
Creates an empty MediaFormat
Public Methods
final boolean containsKey(String name)
Returns true iff a key of the given name exists in the format.
final static MediaFormat createAudioFormat(String mime, int sampleRate, int channelCount)
Creates a minimal audio format.
final static MediaFormat createSubtitleFormat(String mime, String language)
Creates a minimal subtitle format.
final static MediaFormat createVideoFormat(String mime, int width, int height)
Creates a minimal video format.
final ByteBuffer getByteBuffer(String name)
Returns the value of a ByteBuffer key.
boolean getFeatureEnabled(String feature)
Returns whether a feature is to be enabled (true) or disabled (false).
final float getFloat(String name)
Returns the value of a float key.
final int getInteger(String name)
Returns the value of an integer key.
final long getLong(String name)
Returns the value of a long key.
final String getString(String name)
Returns the value of a string key.
final void setByteBuffer(String name, ByteBuffer bytes)
Sets the value of a ByteBuffer key.
void setFeatureEnabled(String feature, boolean enabled)
Sets whether a feature is to be enabled (true) or disabled (false).
final void setFloat(String name, float value)
Sets the value of a float key.
final void setInteger(String name, int value)
Sets the value of an integer key.
final void setLong(String name, long value)
Sets the value of a long key.
final void setString(String name, String value)
Sets the value of a string key.
String toString()
Returns a string containing a concise, human-readable description of this object.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String KEY_AAC_DRC_ATTENUATION_FACTOR

Added in API level 21

A key describing the attenuation factor allowing to adapt the dynamics of the output to the actual listening requirements. See KEY_AAC_DRC_BOOST_FACTOR for a description of the role of this attenuation factor and the value range.

This key is only used during decoding.

Constant Value: "aac-drc-cut-level"

public static final String KEY_AAC_DRC_BOOST_FACTOR

Added in API level 21

A key describing the boost factor allowing to adapt the dynamics of the output to the actual listening requirements. This relies on DRC gain sequences that can be transmitted in the encoded bitstream to be able to reduce the dynamics of the output signal upon request. This factor enables the user to select how much of the gains are applied.

Positive gains (boost) and negative gains (attenuation, see KEY_AAC_DRC_ATTENUATION_FACTOR) can be controlled separately for a better match to different use-cases.

Typically, attenuation gains are sent for loud signal segments, and boost gains are sent for soft signal segments. If the output is listened to in a noisy environment, for example, the boost factor is used to enable the positive gains, i.e. to amplify soft signal segments beyond the noise floor. But for listening late at night, the attenuation factor is used to enable the negative gains, to prevent loud signal from surprising the listener. In applications which generally need a low dynamic range, both the boost factor and the attenuation factor are used in order to enable all DRC gains.

In order to prevent clipping, it is also recommended to apply the attenuation factors in case of a downmix and/or loudness normalization to high target reference levels.

Both the boost and the attenuation factor parameters are given as integer values between 0 and 127, representing the range of the factor of 0 (i.e. don't apply) to 1 (i.e. fully apply boost/attenuation factors respectively).

This key is only used during decoding.

Constant Value: "aac-drc-boost-level"

public static final String KEY_AAC_DRC_HEAVY_COMPRESSION

Added in API level 21

A key describing the selection of the heavy compression profile for DRC. Two separate DRC gain sequences can be transmitted in one bitstream: MPEG-4 DRC light compression, and DVB-specific heavy compression. When selecting the application of the heavy compression, one of the sequences is selected:

  • 0 enables light compression,
  • 1 enables heavy compression instead.
Note that only light compression offers the features of scaling of DRC gains (see KEY_AAC_DRC_BOOST_FACTOR and KEY_AAC_DRC_ATTENUATION_FACTOR for the boost and attenuation factors, and frequency-selective (multiband) DRC. Light compression usually contains clipping prevention for stereo downmixing while heavy compression, if additionally provided in the bitstream, is usually stronger, and contains clipping prevention for stereo and mono downmixing.

The default is light compression.

This key is only used during decoding.

Constant Value: "aac-drc-heavy-compression"

public static final String KEY_AAC_DRC_TARGET_REFERENCE_LEVEL

Added in API level 21

A key describing a gain to be applied so that the output loudness matches the Target Reference Level. This is typically used to normalize loudness across program items. The gain is derived as the difference between the Target Reference Level and the Program Reference Level. The latter can be given in the bitstream and indicates the actual loudness value of the program item.

The value is given as an integer value between 0 and 127, and is calculated as -0.25 * Target Reference Level in dBFS. Therefore, it represents the range of Full Scale (0 dBFS) to -31.75 dBFS.

This key is only used during decoding.

Constant Value: "aac-target-ref-level"

public static final String KEY_AAC_ENCODED_TARGET_LEVEL

Added in API level 21

A key describing the target reference level that was assumed at the encoder for calculation of attenuation gains for clipping prevention. This information can be provided if it is known, otherwise a worst-case assumption is used.

The value is given as an integer value between 0 and 127, and is calculated as -0.25 * Target Reference Level in dBFS. Therefore, it represents the range of Full Scale (0 dBFS) to -31.75 dBFS. The default value is the worst-case assumption of 127.

The value is ignored when heavy compression is used (see KEY_AAC_DRC_HEAVY_COMPRESSION).

This key is only used during decoding.

Constant Value: "aac-encoded-target-level"

public static final String KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT

Added in API level 21

A key describing the maximum number of channels that can be output by the AAC decoder. By default, the decoder will output the same number of channels as present in the encoded stream, if supported. Set this value to limit the number of output channels, and use the downmix information in the stream, if available.

Values larger than the number of channels in the content to decode are ignored.

This key is only used during decoding.

Constant Value: "aac-max-output-channel_count"

public static final String KEY_AAC_PROFILE

Added in API level 16

A key describing the AAC profile to be used (AAC audio formats only). Constants are declared in MediaCodecInfo.CodecProfileLevel.

Constant Value: "aac-profile"

public static final String KEY_AAC_SBR_MODE

Added in API level 21

A key describing the AAC SBR mode to be used (AAC audio formats only). The associated value is an integer and can be set to following values:

  • 0 - no SBR should be applied
  • 1 - single rate SBR
  • 2 - double rate SBR
Note: If this key is not defined the default SRB mode for the desired AAC profile will be used.

This key is only used during encoding.

Constant Value: "aac-sbr-mode"

public static final String KEY_AUDIO_SESSION_ID

Added in API level 21

A key describing the audio session ID of the AudioTrack associated to a tunneled video codec. The associated value is an integer.

Constant Value: "audio-session-id"

public static final String KEY_BITRATE_MODE

Added in API level 21

A key describing the desired bitrate mode to be used by an encoder. Constants are declared in MediaCodecInfo.CodecCapabilities.

Constant Value: "bitrate-mode"

public static final String KEY_BIT_RATE

Added in API level 16

A key describing the bitrate in bits/sec. The associated value is an integer

Constant Value: "bitrate"

public static final String KEY_CAPTURE_RATE

Added in API level 21

A key describing the capture rate of a video format in frames/sec.

When capture rate is different than the frame rate, it means that the video is acquired at a different rate than the playback, which produces slow motion or timelapse effect during playback. Application can use the value of this key to tell the relative speed ratio between capture and playback rates when the video was recorded.

The associated value is an integer or a float.

Constant Value: "capture-rate"

public static final String KEY_CHANNEL_COUNT

Added in API level 16

A key describing the number of channels in an audio format. The associated value is an integer

Constant Value: "channel-count"

public static final String KEY_CHANNEL_MASK

Added in API level 16

A key describing the channel composition of audio content. This mask is composed of bits drawn from channel mask definitions in AudioFormat. The associated value is an integer.

Constant Value: "channel-mask"

public static final String KEY_COLOR_FORMAT

Added in API level 16

A key describing the color format of the content in a video format. Constants are declared in MediaCodecInfo.CodecCapabilities.

Constant Value: "color-format"

public static final String KEY_COMPLEXITY

Added in API level 21

A key describing the encoding complexity. The associated value is an integer. These values are device and codec specific, but lower values generally result in faster and/or less power-hungry encoding.

Constant Value: "complexity"

public static final String KEY_DURATION

Added in API level 16

A key describing the duration (in microseconds) of the content. The associated value is a long.

Constant Value: "durationUs"

public static final String KEY_FLAC_COMPRESSION_LEVEL

Added in API level 16

A key describing the FLAC compression level to be used (FLAC audio format only). The associated value is an integer ranging from 0 (fastest, least compression) to 8 (slowest, most compression).

Constant Value: "flac-compression-level"

public static final String KEY_FRAME_RATE

Added in API level 16

A key describing the frame rate of a video format in frames/sec. The associated value is an integer or a float.

Constant Value: "frame-rate"

public static final String KEY_HEIGHT

Added in API level 16

A key describing the height of the content in a video format. The associated value is an integer

Constant Value: "height"

public static final String KEY_IS_ADTS

Added in API level 16

A key mapping to a value of 1 if the content is AAC audio and audio frames are prefixed with an ADTS header. The associated value is an integer (0 or 1). This key is only supported when _decoding_ content, it cannot be used to configure an encoder to emit ADTS output.

Constant Value: "is-adts"

public static final String KEY_IS_AUTOSELECT

Added in API level 19

A key for boolean AUTOSELECT behavior for the track. Tracks with AUTOSELECT=true are considered when automatically selecting a track without specific user choice, based on the current locale. This is currently only used for subtitle tracks, when the user selected 'Default' for the captioning locale. The associated value is an integer, where non-0 means TRUE. This is an optional field; if not specified, AUTOSELECT defaults to TRUE.

Constant Value: "is-autoselect"

public static final String KEY_IS_DEFAULT

Added in API level 19

A key for boolean DEFAULT behavior for the track. The track with DEFAULT=true is selected in the absence of a specific user choice. This is currently only used for subtitle tracks, when the user selected 'Default' for the captioning locale. The associated value is an integer, where non-0 means TRUE. This is an optional field; if not specified, DEFAULT is considered to be FALSE.

Constant Value: "is-default"

public static final String KEY_IS_FORCED_SUBTITLE

Added in API level 19

A key for the FORCED field for subtitle tracks. True if it is a forced subtitle track. Forced subtitle tracks are essential for the content and are shown even when the user turns off Captions. They are used for example to translate foreign/alien dialogs or signs. The associated value is an integer, where non-0 means TRUE. This is an optional field; if not specified, FORCED defaults to FALSE.

Constant Value: "is-forced-subtitle"

public static final String KEY_I_FRAME_INTERVAL

Added in API level 16

A key describing the frequency of I frames expressed in secs between I frames. The associated value is an integer.

Constant Value: "i-frame-interval"

public static final String KEY_LANGUAGE

Added in API level 19

A key describing the language of the content, using either ISO 639-1 or 639-2/T codes. The associated value is a string.

Constant Value: "language"

public static final String KEY_LEVEL

Added in API level 23

A key describing the desired profile to be used by an encoder. The associated value is an integer. Constants are declared in MediaCodecInfo.CodecProfileLevel. This key is used as a further hint when specifying a desired profile, and is only supported for codecs that specify a level.

This key is ignored if the profile is not specified.

See Also
Constant Value: "level"

public static final String KEY_MAX_HEIGHT

Added in API level 19

A key describing the maximum expected height of the content in a video decoder format, in case there are resolution changes in the video content. The associated value is an integer

Constant Value: "max-height"

public static final String KEY_MAX_INPUT_SIZE

Added in API level 16

A key describing the maximum size in bytes of a buffer of data described by this MediaFormat. The associated value is an integer

Constant Value: "max-input-size"

public static final String KEY_MAX_WIDTH

Added in API level 19

A key describing the maximum expected width of the content in a video decoder format, in case there are resolution changes in the video content. The associated value is an integer

Constant Value: "max-width"

public static final String KEY_MIME

Added in API level 16

A key describing the mime type of the MediaFormat. The associated value is a string.

Constant Value: "mime"

public static final String KEY_OPERATING_RATE

Added in API level 23

A key describing the desired operating frame rate for video or sample rate for audio that the codec will need to operate at.

The associated value is an integer or a float representing frames-per-second or samples-per-second

This is used for cases like high-speed/slow-motion video capture, where the video encoder format contains the target playback rate (e.g. 30fps), but the component must be able to handle the high operating capture rate (e.g. 240fps).

This rate will be used by codec for resource planning and setting the operating points.

Constant Value: "operating-rate"

public static final String KEY_PRIORITY

Added in API level 23

A key describing the desired codec priority.

The associated value is an integer. Higher value means lower priority.

Currently, only two levels are supported:
0: realtime priority - meaning that the codec shall support the given performance configuration (e.g. framerate) at realtime. This should only be used by media playback, capture, and possibly by realtime communication scenarios if best effort performance is not suitable.
1: non-realtime priority (best effort).

This is a hint used at codec configuration and resource planning - to understand the realtime requirements of the application; however, due to the nature of media components, performance is not guaranteed.

Constant Value: "priority"

public static final String KEY_PROFILE

Added in API level 21

A key describing the desired profile to be used by an encoder. The associated value is an integer. Constants are declared in MediaCodecInfo.CodecProfileLevel. This key is used as a hint, and is only supported for codecs that specify a profile.

See Also
Constant Value: "profile"

public static final String KEY_PUSH_BLANK_BUFFERS_ON_STOP

Added in API level 19

If specified when configuring a video decoder rendering to a surface, causes the decoder to output "blank", i.e. black frames to the surface when stopped to clear out any previously displayed contents. The associated value is an integer of value 1.

Constant Value: "push-blank-buffers-on-shutdown"

public static final String KEY_REPEAT_PREVIOUS_FRAME_AFTER

Added in API level 19

Applies only when configuring a video encoder in "surface-input" mode. The associated value is a long and gives the time in microseconds after which the frame previously submitted to the encoder will be repeated (once) if no new frame became available since.

Constant Value: "repeat-previous-frame-after"

public static final String KEY_ROTATION

Added in API level 23

A key describing the desired clockwise rotation on an output surface. This key is only used when the codec is configured using an output surface. The associated value is an integer, representing degrees.

See Also
Constant Value: "rotation-degrees"

public static final String KEY_SAMPLE_RATE

Added in API level 16

A key describing the sample rate of an audio format. The associated value is an integer

Constant Value: "sample-rate"

public static final String KEY_SLICE_HEIGHT

Added in API level 23

A key describing the plane height of a multi-planar (YUV) video bytebuffer layout. Slice height (or plane height) is the number of rows that must be skipped to get from the top of the Y plane to the top of the U plane in the bytebuffer. In essence the offset of the U plane is sliceHeight * stride. The height of the U/V planes can be calculated based on the color format. The associated value is an integer, representing number of rows.

Constant Value: "slice-height"

public static final String KEY_STRIDE

Added in API level 23

A key describing the stride of the video bytebuffer layout. Stride (or row increment) is the difference between the index of a pixel and that of the pixel directly underneath. For YUV 420 formats, the stride corresponds to the Y plane; the stride of the U and V planes can be calculated based on the color format. The associated value is an integer, representing number of bytes.

Constant Value: "stride"

public static final String KEY_TEMPORAL_LAYERING

Added in API level 21

A key describing the temporal layering schema. This is an optional parameter that applies only to video encoders. Use getInputFormat() after configure to query if the encoder supports the desired schema. Supported values are webrtc.vp8.1-layer, webrtc.vp8.2-layer, webrtc.vp8.3-layer, and none. If the encoder does not support temporal layering, the input format will not have an entry with this key. The associated value is a string.

Constant Value: "ts-schema"

public static final String KEY_WIDTH

Added in API level 16

A key describing the width of the content in a video format. The associated value is an integer

Constant Value: "width"

public static final String MIMETYPE_AUDIO_AAC

Added in API level 21

Constant Value: "audio/mp4a-latm"

public static final String MIMETYPE_AUDIO_AC3

Added in API level 21

Constant Value: "audio/ac3"

public static final String MIMETYPE_AUDIO_AMR_NB

Added in API level 21

Constant Value: "audio/3gpp"

public static final String MIMETYPE_AUDIO_AMR_WB

Added in API level 21

Constant Value: "audio/amr-wb"

public static final String MIMETYPE_AUDIO_EAC3

Added in API level 23

Constant Value: "audio/eac3"

public static final String MIMETYPE_AUDIO_FLAC

Added in API level 21

Constant Value: "audio/flac"

public static final String MIMETYPE_AUDIO_G711_ALAW

Added in API level 21

Constant Value: "audio/g711-alaw"

public static final String MIMETYPE_AUDIO_G711_MLAW

Added in API level 21

Constant Value: "audio/g711-mlaw"

public static final String MIMETYPE_AUDIO_MPEG

Added in API level 21

Constant Value: "audio/mpeg"

public static final String MIMETYPE_AUDIO_MSGSM

Added in API level 21

Constant Value: "audio/gsm"

public static final String MIMETYPE_AUDIO_OPUS

Added in API level 21

Constant Value: "audio/opus"

public static final String MIMETYPE_AUDIO_QCELP

Added in API level 21

Constant Value: "audio/qcelp"

public static final String MIMETYPE_AUDIO_RAW

Added in API level 21

Constant Value: "audio/raw"

public static final String MIMETYPE_AUDIO_VORBIS

Added in API level 21

Constant Value: "audio/vorbis"

public static final String MIMETYPE_TEXT_CEA_608

Added in API level 21

MIME type for CEA-608 closed caption data.

Constant Value: "text/cea-608"

public static final String MIMETYPE_TEXT_VTT

Added in API level 21

MIME type for WebVTT subtitle data.

Constant Value: "text/vtt"

public static final String MIMETYPE_VIDEO_AVC

Added in API level 21

Constant Value: "video/avc"

public static final String MIMETYPE_VIDEO_H263

Added in API level 21

Constant Value: "video/3gpp"

public static final String MIMETYPE_VIDEO_HEVC

Added in API level 21

Constant Value: "video/hevc"

public static final String MIMETYPE_VIDEO_MPEG2

Added in API level 21

Constant Value: "video/mpeg2"

public static final String MIMETYPE_VIDEO_MPEG4

Added in API level 21

Constant Value: "video/mp4v-es"

public static final String MIMETYPE_VIDEO_RAW

Added in API level 21

Constant Value: "video/raw"

public static final String MIMETYPE_VIDEO_VP8

Added in API level 21

Constant Value: "video/x-vnd.on2.vp8"

public static final String MIMETYPE_VIDEO_VP9

Added in API level 21

Constant Value: "video/x-vnd.on2.vp9"

Public Constructors

public MediaFormat ()

Added in API level 16

Creates an empty MediaFormat

Public Methods

public final boolean containsKey (String name)

Added in API level 16

Returns true iff a key of the given name exists in the format.

public static final MediaFormat createAudioFormat (String mime, int sampleRate, int channelCount)

Added in API level 16

Creates a minimal audio format.

Parameters
mime The mime type of the content.
sampleRate The sampling rate of the content.
channelCount The number of audio channels in the content.

public static final MediaFormat createSubtitleFormat (String mime, String language)

Added in API level 19

Creates a minimal subtitle format.

Parameters
mime The mime type of the content.
language The language of the content, using either ISO 639-1 or 639-2/T codes. Specify null or "und" if language information is only included in the content. (This will also work if there are multiple language tracks in the content.)

public static final MediaFormat createVideoFormat (String mime, int width, int height)

Added in API level 16

Creates a minimal video format.

Parameters
mime The mime type of the content.
width The width of the content (in pixels)
height The height of the content (in pixels)

public final ByteBuffer getByteBuffer (String name)

Added in API level 16

Returns the value of a ByteBuffer key.

public boolean getFeatureEnabled (String feature)

Added in API level 21

Returns whether a feature is to be enabled (true) or disabled (false).

Parameters
feature the name of a MediaCodecInfo.CodecCapabilities feature.
Throws
IllegalArgumentException if the feature was neither set to be enabled nor to be disabled.

public final float getFloat (String name)

Added in API level 16

Returns the value of a float key.

public final int getInteger (String name)

Added in API level 16

Returns the value of an integer key.

public final long getLong (String name)

Added in API level 16

Returns the value of a long key.

public final String getString (String name)

Added in API level 16

Returns the value of a string key.

public final void setByteBuffer (String name, ByteBuffer bytes)

Added in API level 16

Sets the value of a ByteBuffer key.

public void setFeatureEnabled (String feature, boolean enabled)

Added in API level 21

Sets whether a feature is to be enabled (true) or disabled (false). If enabled is true, the feature is requested to be present. Otherwise, the feature is requested to be not present.

Parameters
feature the name of a MediaCodecInfo.CodecCapabilities feature.

public final void setFloat (String name, float value)

Added in API level 16

Sets the value of a float key.

public final void setInteger (String name, int value)

Added in API level 16

Sets the value of an integer key.

public final void setLong (String name, long value)

Added in API level 16

Sets the value of a long key.

public final void setString (String name, String value)

Added in API level 16

Sets the value of a string key.

public String toString ()

Added in API level 16

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.