MediaFormat
class MediaFormat
kotlin.Any | |
↳ | android.media.MediaFormat |
Encapsulates the information describing the format of media data, be it audio or video, as well as optional feature metadata.
The format of the media data is specified as key/value pairs. Keys are strings. Values can be integer, long, float, String or ByteBuffer.
The feature metadata is specificed as string/boolean pairs.
Keys common to all audio/video formats, all keys not marked optional are mandatory:
Name | Value Type | Description |
---|---|---|
KEY_MIME |
String | The type of the format. |
KEY_CODECS_STRING |
String | optional, the RFC 6381 codecs string of the MediaFormat |
KEY_MAX_INPUT_SIZE |
Integer | optional, maximum size of a buffer of input data |
KEY_PIXEL_ASPECT_RATIO_WIDTH |
Integer | optional, the pixel aspect ratio width |
KEY_PIXEL_ASPECT_RATIO_HEIGHT |
Integer | optional, the pixel aspect ratio height |
KEY_BIT_RATE |
Integer | encoder-only, desired bitrate in bits/second |
KEY_DURATION |
long | the duration of the content (in microseconds) |
Name | Value Type | Description |
---|---|---|
KEY_WIDTH |
Integer | |
KEY_HEIGHT |
Integer | |
KEY_COLOR_FORMAT |
Integer | set by the user for encoders, readable in the output format of decoders |
KEY_FRAME_RATE |
Integer or Float | required for encoders, optional for decoders |
KEY_CAPTURE_RATE |
Integer | |
KEY_I_FRAME_INTERVAL |
Integer (or Float) | encoder-only, time-interval between key frames. Float support added in android.os.Build.VERSION_CODES#N_MR1 |
KEY_INTRA_REFRESH_PERIOD |
Integer | encoder-only, optional |
KEY_LATENCY |
Integer | encoder-only, optional |
KEY_MAX_WIDTH |
Integer | decoder-only, optional, max-resolution width |
KEY_MAX_HEIGHT |
Integer | decoder-only, optional, max-resolution height |
KEY_REPEAT_PREVIOUS_FRAME_AFTER |
Long | encoder in surface-mode only, optional |
KEY_PUSH_BLANK_BUFFERS_ON_STOP |
Integer(1) | decoder rendering to a surface only, optional |
KEY_TEMPORAL_LAYERING |
String | encoder only, optional, temporal-layering schema |
KEY_MAX_WIDTH
and KEY_MAX_HEIGHT
to enable adaptive playback (seamless resolution change) for a video decoder that supports it (MediaCodecInfo.CodecCapabilities#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:
Name | Value Type | Description |
---|---|---|
KEY_CHANNEL_COUNT |
Integer | |
KEY_SAMPLE_RATE |
Integer | |
KEY_PCM_ENCODING |
Integer | optional |
KEY_IS_ADTS |
Integer | optional, if decoding AAC audio content, setting this key to 1 indicates that each audio frame is prefixed by the ADTS header. |
KEY_AAC_PROFILE |
Integer | encoder-only, optional, if content is AAC audio, specifies the desired profile. |
KEY_AAC_SBR_MODE |
Integer | encoder-only, optional, if content is AAC audio, specifies the desired SBR mode. |
KEY_AAC_DRC_TARGET_REFERENCE_LEVEL |
Integer | decoder-only, optional, if content is AAC audio, specifies the target reference level. |
KEY_AAC_ENCODED_TARGET_LEVEL |
Integer | decoder-only, optional, if content is AAC audio, specifies the target reference level used at encoder. |
KEY_AAC_DRC_BOOST_FACTOR |
Integer | decoder-only, optional, if content is AAC audio, specifies the DRC boost factor. |
KEY_AAC_DRC_ATTENUATION_FACTOR |
Integer | decoder-only, optional, if content is AAC audio, specifies the DRC attenuation factor. |
KEY_AAC_DRC_HEAVY_COMPRESSION |
Integer | decoder-only, optional, if content is AAC audio, specifies whether to use heavy compression. |
KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT |
Integer | decoder-only, optional, if content is AAC audio, specifies the maximum number of channels the decoder outputs. |
KEY_AAC_DRC_EFFECT_TYPE |
Integer | decoder-only, optional, if content is AAC audio, specifies the MPEG-D DRC effect type to use. |
KEY_AAC_DRC_OUTPUT_LOUDNESS |
Integer | decoder-only, optional, if content is AAC audio, returns the DRC output loudness. |
KEY_AAC_DRC_ALBUM_MODE |
Integer | decoder-only, optional, if content is AAC audio, specifies the whether MPEG-D DRC Album Mode is active or not. |
KEY_CHANNEL_MASK |
Integer | optional, a mask of audio channel assignments |
KEY_ENCODER_DELAY |
Integer | optional, the number of frames to trim from the start of the decoded audio stream. |
KEY_ENCODER_PADDING |
Integer | optional, the number of frames to trim from the end of the decoded audio stream. |
KEY_FLAC_COMPRESSION_LEVEL |
Integer | encoder-only, optional, if content is FLAC audio, specifies the desired compression level. |
KEY_MPEGH_PROFILE_LEVEL_INDICATION |
Integer | decoder-only, optional, if content is MPEG-H audio, specifies the profile and level of the stream. |
KEY_MPEGH_COMPATIBLE_SETS |
ByteBuffer | decoder-only, optional, if content is MPEG-H audio, specifies the compatible sets (profile and level) of the stream. |
KEY_MPEGH_REFERENCE_CHANNEL_LAYOUT |
Integer | decoder-only, optional, if content is MPEG-H audio, specifies the preferred reference channel layout of the stream. |
KEY_MAX_BUFFER_BATCH_OUTPUT_SIZE | Integer | optional, used with large audio frame support, specifies max size of output buffer in bytes. |
KEY_BUFFER_BATCH_THRESHOLD_OUTPUT_SIZE |
Integer | optional, used with large audio frame support, specifies threshold output size in bytes. |
KEY_MIME |
String | The type of the format. |
KEY_LANGUAGE |
String | The language of the content. |
KEY_CAPTION_SERVICE_NUMBER |
int | optional, the closed-caption service or channel number. |
KEY_MIME |
String | The type of the format. |
KEY_WIDTH |
Integer | |
KEY_HEIGHT |
Integer | |
KEY_COLOR_FORMAT |
Integer | set by the user for encoders, readable in the output format of decoders |
KEY_TILE_WIDTH |
Integer | required if the image has grid |
KEY_TILE_HEIGHT |
Integer | required if the image has grid |
KEY_GRID_ROWS |
Integer | required if the image has grid |
KEY_GRID_COLUMNS |
Integer | required if the image has grid |
Summary
Nested classes | |
---|---|
QpOffsetRect constitutes the metadata required for encoding a region of interest in an image or a video frame. |
Constants | |
---|---|
static Int |
Full range. |
static Int |
Limited range. |
static Int |
BT. |
static Int |
BT. |
static Int |
BT. |
static Int |
BT. |
static Int |
ARIB STD-B67 hybrid-log-gamma transfer function. |
static Int |
Linear transfer characteristic curve. |
static Int |
SMPTE 170M transfer characteristic curve used by BT. |
static Int |
SMPTE ST 2084 transfer function. |
static String |
A key describing the album mode for MPEG-D DRC as defined in ISO/IEC 23003-4. |
static String |
A key describing the attenuation factor allowing to adapt the dynamics of the output to the actual listening requirements. |
static String |
A key describing the boost factor allowing to adapt the dynamics of the output to the actual listening requirements. |
static String |
A key describing for selecting the DRC effect type for MPEG-D DRC. |
static String |
A key describing the selection of the heavy compression profile for MPEG-4 DRC. |
static String |
A key to retrieve the output loudness of a decoded bitstream. |
static String |
A key describing the Target Reference Level (Target Loudness). |
static String |
A key describing the target reference level that was assumed at the encoder for calculation of attenuation gains for clipping prevention. |
static String |
A key describing the maximum number of channels that can be output by the AAC decoder. |
static String |
A key describing the AAC profile to be used (AAC audio formats only). |
static String |
A key describing the AAC SBR mode to be used (AAC audio formats only). |
static String |
A key for applications to opt out of allowing a Surface to discard undisplayed/unconsumed frames as means to catch up after falling behind. |
static String |
A key describing the audio session ID of the AudioTrack associated to a tunneled video codec. |
static String |
A key describing the desired bitrate mode to be used by an encoder. |
static String |
A key describing the average bitrate in bits/sec. |
static String |
A key describing the maximum output buffer size in bytes when using large buffer mode containing multiple access units. |
static String |
A key describing the threshold output size in bytes when using large buffer mode containing multiple access units. |
static String |
A key describing the closed caption service number. |
static String |
A key describing the capture rate of a video format in frames/sec. |
static String |
A key describing the number of channels in an audio format. |
static String |
A key describing the channel composition of audio content. |
static String |
A key describing the codecs string of the MediaFormat. |
static String |
A key describing the color format of the content in a video format. |
static String |
An optional key describing the range of the component values of the video content. |
static String |
An optional key describing the color primaries, white point and luminance factors for video content. |
static String |
An optional key describing the opto-electronic transfer function used for the video content. |
static String |
An optional key describing the opto-electronic transfer function requested for the output video content. |
static String |
A key describing the encoding complexity. |
static String |
If specified when configuring a video encoder that's in "surface-input" mode, it will instruct the encoder to put the surface source in suspended state when it's connected. |
static String |
A key describing the bottom-coordinate (y) of the crop rectangle. |
static String |
A key describing the left-coordinate (x) of the crop rectangle. |
static String |
A key describing the right-coordinate (x) of the crop rectangle. |
static String |
A key describing the top-coordinate (y) of the crop rectangle. |
static String |
A key describing the duration (in microseconds) of the content. |
static String |
A key describing the number of frames to trim from the start of the decoded audio stream. |
static String |
A key describing the number of frames to trim from the end of the decoded audio stream. |
static String |
A key describing the FLAC compression level to be used (FLAC audio format only). |
static String |
A key describing the frame rate of a video format in frames/sec. |
static String |
A key describing the number of grid columns in the content in a |
static String |
A key describing the number of grid rows in the content in a |
static String |
A key describing the number of haptic channels in an audio format. |
static String |
A key describing the hardware AV sync id. |
static String |
An optional key describing the HDR10+ metadata of the video content. |
static String |
An optional key describing the static metadata of HDR (high-dynamic-range) video content. |
static String |
A key describing the height of the content in a video format. |
static String |
A key describing the desired codec importance for the application. |
static String |
An optional key describing the period of intra refresh in frames. |
static String |
A key mapping to a value of 1 if the content is AAC audio and audio frames are prefixed with an ADTS header. |
static String |
A key for boolean AUTOSELECT behavior for the track. |
static String |
A key for boolean DEFAULT behavior for the track. |
static String |
A key for the FORCED field for subtitle tracks. |
static String |
A key describing the frequency of key frames expressed in seconds between key frames. |
static String |
A key describing the language of the content, using either ISO 639-1 or 639-2/T codes. |
static String |
An optional key describing the desired encoder latency in frames. |
static String |
A key describing the desired profile to be used by an encoder. |
static String |
An optional key describing the low latency decoding mode. |
static String |
A key describing the maximum number of B frames between I or P frames, to be used by a video encoder. |
static String |
Instruct the video encoder in "surface-input" mode to drop excessive frames from the source, so that the input frame rate to the encoder does not exceed the specified fps. |
static String |
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. |
static String |
A key describing the maximum size in bytes of a buffer of data described by this MediaFormat. |
static String |
A key describing the maximum number of channels that can be output by an audio decoder. |
static String |
Instruct the video encoder in "surface-input" mode to limit the gap of timestamp between any two adjacent frames fed to the encoder to the specified amount (in micro-second). |
static String |
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. |
static String |
A key describing the mime type of the MediaFormat. |
static String |
A key describing the MPEG-H stream compatible sets. |
static String |
A key describing the MPEG-H stream profile-level indication. |
static String |
A key describing the MPEG-H stream reference channel layout. |
static String |
A key describing the desired operating frame rate for video or sample rate for audio that the codec will need to operate at. |
static String |
An optional key describing the maximum number of non-display-order coded frames. |
static String |
A key describing the raw audio sample encoding/format. |
static String |
A key describing the picture type of the encoded frame. |
static String |
A key describing the pixel aspect ratio height. |
static String |
A key describing the pixel aspect ratio width. |
static String |
An optional key describing whether encoders prepend headers to sync frames (e.g. SPS and PPS to IDR frames for H.264). |
static String |
A key describing the desired codec priority. |
static String |
A key describing the desired profile to be used by an encoder. |
static String |
If specified when configuring a video decoder rendering to a surface, causes the decoder to output "blank", i. |
static String |
A key describing the desired encoding quality. |
static String |
Applies only when configuring a video encoder in "surface-input" mode. |
static String |
A key describing the desired clockwise rotation on an output surface. |
static String |
A key describing the sample rate of an audio format. |
static String |
A key describing the plane height of a multi-planar (YUV) video bytebuffer layout. |
static String |
A key for retrieving the slow-motion marker information associated with a video track. |
static String |
A key describing the stride of the video bytebuffer layout. |
static String |
A key describing the temporal layering schema. |
static String |
A key describing the height (in pixels) of each tile of the content in a |
static String |
A key describing the width (in pixels) of each tile of the content in a |
static String |
A key describing a unique ID for the content of a media track. |
static String |
A key describing the level of encoding statistics information emitted from video encoder. |
static String |
A key describing the per-frame average block QP (Quantization Parameter). |
static String |
A key describing the maximum Quantization Parameter allowed for encoding video. |
static String |
A key describing the minimum Quantization Parameter allowed for encoding video. |
static String |
A key describing the maximum Quantization Parameter allowed for encoding video. |
static String |
A key describing the minimum Quantization Parameter allowed for encoding video. |
static String |
A key describing the maximum Quantization Parameter allowed for encoding video. |
static String |
A key describing the minimum Quantization Parameter allowed for encoding video. |
static String |
A key describing the maximum Quantization Parameter allowed for encoding video. |
static String |
A key describing the minimum Quantization Parameter allowed for encoding video. |
static String |
A key describing the width of the content in a video format. |
static String |
A key describing the log session ID for MediaCodec. |
static String | |
static String |
MIME type for AAC Enhanced Low Delay (ELD) audio stream. |
static String |
MIME type for HE-AAC v1 (LC + SBR) audio stream. |
static String |
MIME type for HE-AAC v2 (LC + SBR + PS) audio stream. |
static String |
MIME type for AAC Low Complexity (LC) audio stream. |
static String |
MIME type for AAC XHE audio stream. |
static String | |
static String | |
static String | |
static String | |
static String |
MIME type for Dolby Metadata-enhanced Audio Transmission (MAT) audio stream. |
static String |
MIME type for Dolby TrueHD audio format, based on Meridian Lossless Packing (MLP). |
static String |
MIME type for Dynamic Resolution Adaptation (DRA) audio stream. |
static String |
MIME type for DTS Digital Surround (up to 5.1 channels) audio stream, aka DTS-CA. |
static String |
MIME type for DTS HD (up to 7.1 channels) audio stream. |
static String |
MIME type for DTS UHD (object-based) audio stream, aka DTS:X. |
static String | |
static String | |
static String | |
static String | |
static String | |
static String |
MIME type for the IEC61937 audio stream encapsulation. |
static String | |
static String |
MIME type for MPEG-H Baseline (BL) Profile L3 audio stream. |
static String |
MIME type for MPEG-H Baseline (BL) Profile L4 audio stream. |
static String |
MIME type for MPEG-H Low Complexity (LC) L3 audio stream. |
static String |
MIME type for MPEG-H Low Complexity (LC) L4 audio stream. |
static String |
MIME type for MPEG-H Audio single stream |
static String |
MIME type for MPEG-H Audio single stream, encapsulated in MHAS |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String |
MIME type for HEIF still image data encoded in HEVC. |
static String |
MIME type for AVIF still image data encoded in AV1. |
static String |
MIME type for CEA-608 closed caption data. |
static String |
MIME type for CEA-708 closed caption data. |
static String |
MIME type for SubRip (SRT) container. |
static String |
MIME type for WebVTT subtitle data. |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static String | |
static Int |
Picture Type is B Frame. |
static Int |
Picture Type is I Frame. |
static Int |
Picture Type is P Frame. |
static Int |
Picture Type is unknown. |
static Int | |
static Int | |
static Int | |
static Int | |
static Int | |
static Int | |
static Int |
Encoding Statistics Level 1. |
static Int |
Encoding Statistics Level None. |
Public constructors | |
---|---|
Creates an empty MediaFormat |
|
MediaFormat(other: MediaFormat) Create a copy of a media format object. |
Public methods | |
---|---|
Boolean |
containsFeature(name: String) Returns true iff a feature of the given name exists in the format. |
Boolean |
containsKey(name: String) Returns true iff a key of the given name exists in the format. |
static MediaFormat |
createAudioFormat(mime: String, sampleRate: Int, channelCount: Int) Creates a minimal audio format. |
static MediaFormat |
createSubtitleFormat(mime: String, language: String!) Creates a minimal subtitle format. |
static MediaFormat |
createVideoFormat(mime: String, width: Int, height: Int) Creates a minimal video format. |
ByteBuffer? |
getByteBuffer(name: String) Returns the value of a ByteBuffer key. |
ByteBuffer |
getByteBuffer(name: String, defaultValue: ByteBuffer) Returns the value of a ByteBuffer key, or the default value if the key is missing. |
Boolean |
getFeatureEnabled(feature: String) Returns whether a feature is to be enabled ( |
MutableSet<String!> |
Returns a |
Float |
Returns the value of a float key. |
Float |
Returns the value of a float key, or the default value if the key is missing. |
Int |
getInteger(name: String) Returns the value of an integer key. |
Int |
getInteger(name: String, defaultValue: Int) Returns the value of an integer key, or the default value if the key is missing. |
MutableSet<String!> |
getKeys() Returns a |
Long |
Returns the value of a long key. |
Long |
Returns the value of a long key, or the default value if the key is missing. |
Number? |
Returns the value of a numeric key. |
Number |
Returns the value of a numeric key, or the default value if the key is missing. |
String? |
Returns the value of a string key. |
String |
Returns the value of a string key, or the default value if the key is missing. |
Int |
getValueTypeForKey(name: String) Returns the value type for a key. |
Unit |
removeFeature(name: String) Removes a given feature setting if present. |
Unit |
Removes a value of a given key if present. |
Unit |
setByteBuffer(name: String, bytes: ByteBuffer?) Sets the value of a ByteBuffer key. |
Unit |
setFeatureEnabled(feature: String, enabled: Boolean) Sets whether a feature is to be enabled ( |
Unit |
Sets the value of a float key. |
Unit |
setInteger(name: String, value: Int) Sets the value of an integer key. |
Unit |
Sets the value of a long key. |
Unit |
Sets the value of a string key. |
String |
toString() Returns a string representation of the object. |
Constants
COLOR_RANGE_FULL
static val COLOR_RANGE_FULL: Int
Full range. Y, Cr and Cb component values range from 0 to 255 for 8-bit content.
Value: 1
COLOR_RANGE_LIMITED
static val COLOR_RANGE_LIMITED: Int
Limited range. Y component values range from 16 to 235 for 8-bit content. Cr, Cy values range from 16 to 240 for 8-bit content. This is the default for video content.
Value: 2
COLOR_STANDARD_BT2020
static val COLOR_STANDARD_BT2020: Int
BT.2020 color chromacity coordinates with KR = 0.2627, KB = 0.0593.
Value: 6
COLOR_STANDARD_BT601_NTSC
static val COLOR_STANDARD_BT601_NTSC: Int
BT.601 525 color chromacity coordinates with KR = 0.299, KB = 0.114.
Value: 4
COLOR_STANDARD_BT601_PAL
static val COLOR_STANDARD_BT601_PAL: Int
BT.601 625 color chromacity coordinates with KR = 0.299, KB = 0.114.
Value: 2
COLOR_STANDARD_BT709
static val COLOR_STANDARD_BT709: Int
BT.709 color chromacity coordinates with KR = 0.2126, KB = 0.0722.
Value: 1
COLOR_TRANSFER_HLG
static val COLOR_TRANSFER_HLG: Int
ARIB STD-B67 hybrid-log-gamma transfer function. This is used by some HDR video content.
Value: 7
COLOR_TRANSFER_LINEAR
static val COLOR_TRANSFER_LINEAR: Int
Linear transfer characteristic curve.
Value: 1
COLOR_TRANSFER_SDR_VIDEO
static val COLOR_TRANSFER_SDR_VIDEO: Int
SMPTE 170M transfer characteristic curve used by BT.601/BT.709/BT.2020. This is the curve used by most non-HDR video content.
Value: 3
COLOR_TRANSFER_ST2084
static val COLOR_TRANSFER_ST2084: Int
SMPTE ST 2084 transfer function. This is used by some HDR video content.
Value: 6
KEY_AAC_DRC_ALBUM_MODE
static val KEY_AAC_DRC_ALBUM_MODE: String
A key describing the album mode for MPEG-D DRC as defined in ISO/IEC 23003-4.
The associated value is an integer and can be set to following values:
Value | Album Mode |
---|---|
0 | disabled |
1 | enabled |
Disabled album mode leads to application of gain sequences for fading in and out, if provided in the bitstream. Enabled album mode makes use of dedicated album loudness information, if provided in the bitstream.
The default value is 0 (album mode disabled).
This key is only used during decoding.
Value: "aac-drc-album-mode"
KEY_AAC_DRC_ATTENUATION_FACTOR
static val KEY_AAC_DRC_ATTENUATION_FACTOR: String
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.
The default value is 127 (fully apply attenuation DRC gains).
This key is only used during decoding.
Value: "aac-drc-cut-level"
KEY_AAC_DRC_BOOST_FACTOR
static val KEY_AAC_DRC_BOOST_FACTOR: String
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 gains 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 gains respectively).
The default value is 127 (fully apply boost DRC gains).
This key is only used during decoding.
Value: "aac-drc-boost-level"
KEY_AAC_DRC_EFFECT_TYPE
static val KEY_AAC_DRC_EFFECT_TYPE: String
A key describing for selecting the DRC effect type for MPEG-D DRC. The supported values are defined in ISO/IEC 23003-4:2015 and are described as follows:
Value | Effect |
---|---|
-1 | Off |
0 | None |
1 | Late night |
2 | Noisy environment |
3 | Limited playback range |
4 | Low playback level |
5 | Dialog enhancement |
6 | General compression |
The value -1 (Off) disables DRC processing, while loudness normalization may still be active and dependent on KEY_AAC_DRC_TARGET_REFERENCE_LEVEL
.
The value 0 (None) automatically enables DRC processing if necessary to prevent signal clipping
The value 6 (General compression) can be used for enabling MPEG-D DRC without particular DRC effect type request.
The default DRC effect type is 3 ("Limited playback range") on mobile devices.
This key is only used during decoding.
Value: "aac-drc-effect-type"
KEY_AAC_DRC_HEAVY_COMPRESSION
static val KEY_AAC_DRC_HEAVY_COMPRESSION: String
A key describing the selection of the heavy compression profile for MPEG-4 DRC.
Two separate DRC gain sequences can be transmitted in one bitstream: light compression and 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.
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 1 (heavy compression).
This key is only used during decoding.
Value: "aac-drc-heavy-compression"
KEY_AAC_DRC_OUTPUT_LOUDNESS
static val KEY_AAC_DRC_OUTPUT_LOUDNESS: String
A key to retrieve the output loudness of a decoded bitstream.
If loudness normalization is active, the value corresponds to the Target Reference Level (see KEY_AAC_DRC_TARGET_REFERENCE_LEVEL
).
If loudness normalization is not active, the value corresponds to the loudness metadata given in the bitstream.
The value is retrieved with getInteger() and is given as an integer value between 0 and 231. It is calculated as -4 * Output Loudness in LKFS. Therefore, it represents the range of 0 to -57.75 LKFS.
A value of -1 indicates that no loudness metadata is present in the bitstream.
Loudness metadata can originate from MPEG-4 DRC or MPEG-D DRC.
This key is only used during decoding.
Value: "aac-drc-output-loudness"
KEY_AAC_DRC_TARGET_REFERENCE_LEVEL
static val KEY_AAC_DRC_TARGET_REFERENCE_LEVEL: String
A key describing the Target Reference Level (Target Loudness).
For normalizing loudness across program items, a gain is applied to the audio output so that the output loudness matches the Target Reference Level. The gain is derived as the difference between the Target Reference Level and the Program Reference Level (Program Loudness). The latter can be given in the bitstream and indicates the actual loudness value of the program item.
The Target Reference Level controls loudness normalization for both MPEG-4 DRC and MPEG-D DRC.
The value is given as an integer value between 40 and 127, and is calculated as -4 * Target Reference Level in LKFS. Therefore, it represents the range of -10 to -31.75 LKFS.
For MPEG-4 DRC, a value of -1 switches off loudness normalization and DRC processing.
For MPEG-D DRC, a value of -1 switches off loudness normalization only. For DRC processing options of MPEG-D DRC, see KEY_AAC_DRC_EFFECT_TYPE
The default value on mobile devices is 64 (-16 LKFS).
This key is only used during decoding.
Value: "aac-target-ref-level"
KEY_AAC_ENCODED_TARGET_LEVEL
static val KEY_AAC_ENCODED_TARGET_LEVEL: String
A key describing the target reference level that was assumed at the encoder for calculation of attenuation gains for clipping prevention.
If it is known, this information can be provided as an integer value between 0 and 127, which is calculated as -4 * Encoded Target Level in LKFS. If the Encoded Target Level is unknown, the value can be set to -1.
The default value is -1 (unknown).
The value is ignored when heavy compression (see KEY_AAC_DRC_HEAVY_COMPRESSION
) or MPEG-D DRC is used.
This key is only used during decoding.
Value: "aac-encoded-target-level"
KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT
static valKEY_AAC_MAX_OUTPUT_CHANNEL_COUNT: String
Deprecated: Use the non-AAC-specific key KEY_MAX_OUTPUT_CHANNEL_COUNT
instead
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 behave just like the actual channel count of the content (e.g. passing 99 for the decoding of 5.1 content will behave like using 6).
This key is only used during decoding.
Value: "aac-max-output-channel_count"
KEY_AAC_PROFILE
static val KEY_AAC_PROFILE: String
A key describing the AAC profile to be used (AAC audio formats only). Constants are declared in android.media.MediaCodecInfo.CodecProfileLevel
.
Value: "aac-profile"
KEY_AAC_SBR_MODE
static val KEY_AAC_SBR_MODE: String
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
This key is only used during encoding.
Value: "aac-sbr-mode"
KEY_ALLOW_FRAME_DROP
static val KEY_ALLOW_FRAME_DROP: String
A key for applications to opt out of allowing a Surface to discard undisplayed/unconsumed frames as means to catch up after falling behind. This value is an integer. The value 0 indicates the surface is not allowed to drop frames. The value 1 indicates the surface is allowed to drop frames. MediaCodec
describes the semantics.
Value: "allow-frame-drop"
KEY_AUDIO_SESSION_ID
static val KEY_AUDIO_SESSION_ID: String
A key describing the audio session ID of the AudioTrack associated to a tunneled video codec. The associated value is an integer.
Value: "audio-session-id"
KEY_BITRATE_MODE
static val KEY_BITRATE_MODE: String
A key describing the desired bitrate mode to be used by an encoder. Constants are declared in MediaCodecInfo.EncoderCapabilities
.
Value: "bitrate-mode"
KEY_BIT_RATE
static val KEY_BIT_RATE: String
A key describing the average bitrate in bits/sec. The associated value is an integer
Value: "bitrate"
KEY_BUFFER_BATCH_MAX_OUTPUT_SIZE
static val KEY_BUFFER_BATCH_MAX_OUTPUT_SIZE: String
A key describing the maximum output buffer size in bytes when using large buffer mode containing multiple access units. When not-set - codec functions with one access-unit per frame. When set less than the size of two access-units - will make codec operate in single access-unit per output frame. When set to a value too big - The component or the framework will override this value to a reasonable max size not exceeding typical 10 seconds of data (device dependent) when set to a value larger than that. The value final value used will be returned in the output format. The associated value is an integer
Value: "buffer-batch-max-output-size"
See Also
KEY_BUFFER_BATCH_THRESHOLD_OUTPUT_SIZE
static val KEY_BUFFER_BATCH_THRESHOLD_OUTPUT_SIZE: String
A key describing the threshold output size in bytes when using large buffer mode containing multiple access units. This is an optional parameter. If not set - the component can set this to a reasonable value. If set larger than max size, the components will clip this setting to maximum buffer batching output size. The component will return a partial output buffer if the output buffer reaches or surpass this limit. Threshold size should be always less or equal to KEY_MAX_BUFFER_BATCH_OUTPUT_SIZE. The final setting of this value as determined by the component will be returned in the output format The associated value is an integer
Value: "buffer-batch-threshold-output-size"
See Also
KEY_CAPTION_SERVICE_NUMBER
static val KEY_CAPTION_SERVICE_NUMBER: String
A key describing the closed caption service number. For CEA-608 caption tracks, holds the channel number. For CEA-708, holds the service number. The associated value is an int.
Value: "caption-service-number"
KEY_CAPTURE_RATE
static val KEY_CAPTURE_RATE: String
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.
Value: "capture-rate"
KEY_CHANNEL_COUNT
static val KEY_CHANNEL_COUNT: String
A key describing the number of channels in an audio format. The associated value is an integer
Value: "channel-count"
KEY_CHANNEL_MASK
static val KEY_CHANNEL_MASK: String
A key describing the channel composition of audio content. This mask is composed of bits drawn from channel mask definitions in android.media.AudioFormat
. The associated value is an integer.
Value: "channel-mask"
KEY_CODECS_STRING
static val KEY_CODECS_STRING: String
A key describing the codecs string of the MediaFormat. See RFC 6381 section 3.2 for the syntax of the value. The value does not hold MediaCodec
-exposed codec names. The associated value is a string.
Value: "codecs-string"
KEY_COLOR_FORMAT
static val KEY_COLOR_FORMAT: String
A key describing the color format of the content in a video format. Constants are declared in android.media.MediaCodecInfo.CodecCapabilities
.
Value: "color-format"
KEY_COLOR_RANGE
static val KEY_COLOR_RANGE: String
An optional key describing the range of the component values of the video content. The associated value is an integer: 0 if unspecified, or one of the COLOR_RANGE_ values.
Value: "color-range"
KEY_COLOR_STANDARD
static val KEY_COLOR_STANDARD: String
An optional key describing the color primaries, white point and luminance factors for video content. The associated value is an integer: 0 if unspecified, or one of the COLOR_STANDARD_ values.
Value: "color-standard"
KEY_COLOR_TRANSFER
static val KEY_COLOR_TRANSFER: String
An optional key describing the opto-electronic transfer function used for the video content. The associated value is an integer: 0 if unspecified, or one of the COLOR_TRANSFER_ values.
Value: "color-transfer"
KEY_COLOR_TRANSFER_REQUEST
static val KEY_COLOR_TRANSFER_REQUEST: String
An optional key describing the opto-electronic transfer function requested for the output video content. The associated value is an integer: 0 if unspecified, or one of the COLOR_TRANSFER_ values. When unspecified the component will not touch the video content; otherwise the component will tone-map the raw video frame to match the requested transfer function. After configure, component's input format will contain this key to note whether the request is supported or not. If the value in the input format is the same as the requested value, the request is supported. The value is set to 0 if unsupported.
Value: "color-transfer-request"
KEY_COMPLEXITY
static val KEY_COMPLEXITY: String
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.
Value: "complexity"
KEY_CREATE_INPUT_SURFACE_SUSPENDED
static val KEY_CREATE_INPUT_SURFACE_SUSPENDED: String
If specified when configuring a video encoder that's in "surface-input" mode, it will instruct the encoder to put the surface source in suspended state when it's connected. No video frames will be accepted until a resume operation (see MediaCodec#PARAMETER_KEY_SUSPEND
), optionally with timestamp specified via MediaCodec#PARAMETER_KEY_SUSPEND_TIME
, is received. The value is an integer, with 1 indicating to create with the surface source suspended, or 0 otherwise. The default value is 0. If this key is not set or set to 0, the surface source will accept buffers as soon as it's connected to the encoder (although they may not be encoded immediately). This key can be used when the client wants to prepare the encoder session in advance, but do not want to accept buffers immediately.
Value: "create-input-buffers-suspended"
KEY_CROP_BOTTOM
static val KEY_CROP_BOTTOM: String
A key describing the bottom-coordinate (y) of the crop rectangle. This is the bottom-most row included in the crop frame, where row indices start at 0. Additional information on the crop rectangle semantics can be found at android.media.MediaCodec
.
Value: "crop-bottom"
KEY_CROP_LEFT
static val KEY_CROP_LEFT: String
A key describing the left-coordinate (x) of the crop rectangle. This is the left-most column included in the crop frame, where column indices start at 0. Additional information on the crop rectangle semantics can be found at android.media.MediaCodec
.
Value: "crop-left"
KEY_CROP_RIGHT
static val KEY_CROP_RIGHT: String
A key describing the right-coordinate (x) of the crop rectangle. This is the right-most column included in the crop frame, where column indices start at 0. Additional information on the crop rectangle semantics can be found at android.media.MediaCodec
.
Value: "crop-right"
KEY_CROP_TOP
static val KEY_CROP_TOP: String
A key describing the top-coordinate (y) of the crop rectangle. This is the top-most row included in the crop frame, where row indices start at 0. Additional information on the crop rectangle semantics can be found at android.media.MediaCodec
.
Value: "crop-top"
KEY_DURATION
static val KEY_DURATION: String
A key describing the duration (in microseconds) of the content. The associated value is a long.
Value: "durationUs"
KEY_ENCODER_DELAY
static val KEY_ENCODER_DELAY: String
A key describing the number of frames to trim from the start of the decoded audio stream. The associated value is an integer.
Value: "encoder-delay"
KEY_ENCODER_PADDING
static val KEY_ENCODER_PADDING: String
A key describing the number of frames to trim from the end of the decoded audio stream. The associated value is an integer.
Value: "encoder-padding"
KEY_FLAC_COMPRESSION_LEVEL
static val KEY_FLAC_COMPRESSION_LEVEL: String
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).
Value: "flac-compression-level"
KEY_FRAME_RATE
static val KEY_FRAME_RATE: String
A key describing the frame rate of a video format in frames/sec.
The associated value is normally an integer when the value is used by the platform, but video codecs also accept float configuration values. Specifically, MediaExtractor
provides an integer value corresponding to the frame rate information of the track if specified and non-zero. Otherwise, this key is not present. android.media.MediaCodec#configure accepts both float and integer values.
This represents the desired operating frame rate if the KEY_OPERATING_RATE
is not present and KEY_PRIORITY
is 0
(realtime). Otherwise, this is just informational.
For video encoders this value corresponds to the intended frame rate (the rate at which the application intends to send frames to the encoder, as calculated by the buffer timestamps, and not from the actual real-time rate that the frames are sent to the encoder). Encoders use this hint for rate control, specifically for the initial frames, as encoders are expected to support variable frame rate (for rate control) based on the actual buffer timestamps
of subsequent frames.
This key is not used in the MediaCodec
input
/android.media.MediaCodec#getOutputFormat formats, nor by MediaMuxer
.
Value: "frame-rate"
KEY_GRID_COLUMNS
static val KEY_GRID_COLUMNS: String
A key describing the number of grid columns in the content in a MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
track. The associated value is an integer. Refer to MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
on decoding instructions of such tracks.
Value: "grid-cols"
KEY_GRID_ROWS
static val KEY_GRID_ROWS: String
A key describing the number of grid rows in the content in a MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
track. The associated value is an integer. Refer to MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
on decoding instructions of such tracks.
Value: "grid-rows"
KEY_HAPTIC_CHANNEL_COUNT
static val KEY_HAPTIC_CHANNEL_COUNT: String
A key describing the number of haptic channels in an audio format. The associated value is an integer.
Value: "haptic-channel-count"
KEY_HARDWARE_AV_SYNC_ID
static val KEY_HARDWARE_AV_SYNC_ID: String
A key describing the hardware AV sync id. The associated value is an integer See android.media.tv.tuner.Tuner#getAvSyncHwId.
Value: "hw-av-sync-id"
KEY_HDR10_PLUS_INFO
static val KEY_HDR10_PLUS_INFO: String
An optional key describing the HDR10+ metadata of the video content. The associated value is a ByteBuffer containing HDR10+ metadata conforming to the user_data_registered_itu_t_t35() syntax of SEI message for ST 2094-40. This key will be present on:
- The formats of output buffers of a decoder configured for HDR10+ profiles (such as MediaCodecInfo.CodecProfileLevel#VP9Profile2HDR10Plus
, android.media.MediaCodecInfo.CodecProfileLevel#VP9Profile3HDR10Plus
or android.media.MediaCodecInfo.CodecProfileLevel#HEVCProfileMain10HDR10Plus
), or
- The formats of output buffers of an encoder configured for an HDR10+ profiles that uses out-of-band metadata (such as android.media.MediaCodecInfo.CodecProfileLevel#VP9Profile2HDR10Plus
or android.media.MediaCodecInfo.CodecProfileLevel#VP9Profile3HDR10Plus
).
Value: "hdr10-plus-info"
KEY_HDR_STATIC_INFO
static val KEY_HDR_STATIC_INFO: String
An optional key describing the static metadata of HDR (high-dynamic-range) video content. The associated value is a ByteBuffer. This buffer contains the raw contents of the Static Metadata Descriptor (including the descriptor ID) of an HDMI Dynamic Range and Mastering InfoFrame as defined by CTA-861.3. This key must be provided to video decoders for HDR video content unless this information is contained in the bitstream and the video decoder supports an HDR-capable profile. This key must be provided to video encoders for HDR video content.
Value: "hdr-static-info"
KEY_HEIGHT
static val KEY_HEIGHT: String
A key describing the height of the content in a video format. The associated value is an integer
Value: "height"
KEY_IMPORTANCE
static val KEY_IMPORTANCE: String
A key describing the desired codec importance for the application.
The associated value is a positive integer including zero. Higher value means lesser importance.
The resource manager may use the codec importance, along with other factors when reclaiming codecs from an application. The specifics of reclaim policy is device dependent, but specifying the codec importance, will allow the resource manager to prioritize reclaiming less important codecs (assigned higher values) from the (reclaim) requesting application first. So, the codec importance is only relevant within the context of that application.
The codec importance can be set:
- through android.media.MediaCodec#configure.
- through
MediaCodec#setParameters
if the codec has been configured already, which allows the users to change the codec importance multiple times.
Value: "importance"
KEY_INTRA_REFRESH_PERIOD
static val KEY_INTRA_REFRESH_PERIOD: String
An optional key describing the period of intra refresh in frames. This is an optional parameter that applies only to video encoders. If encoder supports it (MediaCodecInfo.CodecCapabilities#FEATURE_IntraRefresh
), the whole frame is completely refreshed after the specified period. Also for each frame, a fix subset of macroblocks must be intra coded which leads to more constant bitrate than inserting a key frame. This key is recommended for video streaming applications as it provides low-delay and good error-resilience. This key is ignored if the video encoder does not support the intra refresh feature. Use the output format to verify that this feature was enabled. The associated value is an integer.
Value: "intra-refresh-period"
KEY_IS_ADTS
static val KEY_IS_ADTS: String
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.
Value: "is-adts"
KEY_IS_AUTOSELECT
static val KEY_IS_AUTOSELECT: String
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.
Value: "is-autoselect"
KEY_IS_DEFAULT
static val KEY_IS_DEFAULT: String
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 used in two scenarios: 1) for subtitle tracks, when the user selected 'Default' for the captioning locale. 2) for a MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
track, indicating the image is the primary item in the file. 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.
Value: "is-default"
KEY_IS_FORCED_SUBTITLE
static val KEY_IS_FORCED_SUBTITLE: String
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.
Value: "is-forced-subtitle"
KEY_I_FRAME_INTERVAL
static val KEY_I_FRAME_INTERVAL: String
A key describing the frequency of key frames expressed in seconds between key frames.
This key is used by video encoders. A negative value means no key frames are requested after the first frame. A zero value means a stream containing all key frames is requested.
Most video encoders will convert this value of the number of non-key-frames between key-frames, using the frame rate information; therefore, if the actual frame rate differs (e.g. input frames are dropped or the frame rate changes), the time interval between key frames will not be the configured value.
The associated value is an integer (or float since android.os.Build.VERSION_CODES#N_MR1
).
Value: "i-frame-interval"
KEY_LANGUAGE
static val KEY_LANGUAGE: String
A key describing the language of the content, using either ISO 639-1 or 639-2/T codes. The associated value is a string.
Value: "language"
KEY_LATENCY
static val KEY_LATENCY: String
An optional key describing the desired encoder latency in frames. This is an optional parameter that applies only to video encoders. If encoder supports it, it should ouput at least one output frame after being queued the specified number of frames. This key is ignored if the video encoder does not support the latency feature. Use the output format to verify that this feature was enabled and the actual value used by the encoder.
If the key is not specified, the default latency will be implenmentation specific. The associated value is an integer.
Value: "latency"
KEY_LEVEL
static val KEY_LEVEL: String
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. Otherwise, the value should be a level compatible with the configured encoding parameters.
Note: This key cannot be used to constrain the encoder's output to a maximum encoding level. Encoders are free to target a different level if the configured encoding parameters dictate it. Nevertheless, encoders shall use (and encode) a level sufficient to decode the generated bitstream, though they may exceed the (Video) Buffering Verifier limits for that encoded level.
Value: "level"
KEY_LOW_LATENCY
static val KEY_LOW_LATENCY: String
An optional key describing the low latency decoding mode. This is an optional parameter that applies only to decoders. If enabled, the decoder doesn't hold input and output data more than required by the codec standards. The associated value is an integer (0 or 1): 1 when low-latency decoding is enabled, 0 otherwise. The default value is 0.
Value: "low-latency"
KEY_MAX_B_FRAMES
static val KEY_MAX_B_FRAMES: String
A key describing the maximum number of B frames between I or P frames, to be used by a video encoder. The associated value is an integer. The default value is 0, which means that no B frames are allowed. Note that non-zero value does not guarantee B frames; it's up to the encoder to decide.
Value: "max-bframes"
KEY_MAX_FPS_TO_ENCODER
static val KEY_MAX_FPS_TO_ENCODER: String
Instruct the video encoder in "surface-input" mode to drop excessive frames from the source, so that the input frame rate to the encoder does not exceed the specified fps. The associated value is a float, representing the max frame rate to feed the encoder at.
Value: "max-fps-to-encoder"
KEY_MAX_HEIGHT
static val KEY_MAX_HEIGHT: String
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
Value: "max-height"
KEY_MAX_INPUT_SIZE
static val KEY_MAX_INPUT_SIZE: String
A key describing the maximum size in bytes of a buffer of data described by this MediaFormat. The associated value is an integer
Value: "max-input-size"
KEY_MAX_OUTPUT_CHANNEL_COUNT
static val KEY_MAX_OUTPUT_CHANNEL_COUNT: String
A key describing the maximum number of channels that can be output by an audio 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 behave like the number of channels in the content (if applicable), for instance passing 99 for a 5.1 audio stream behaves like passing 6.
This key is only used during decoding.
Value: "max-output-channel-count"
KEY_MAX_PTS_GAP_TO_ENCODER
static val KEY_MAX_PTS_GAP_TO_ENCODER: String
Instruct the video encoder in "surface-input" mode to limit the gap of timestamp between any two adjacent frames fed to the encoder to the specified amount (in micro-second). The associated value is a long int. When positive, it represents the max timestamp gap between two adjacent frames fed to the encoder. When negative, the absolute value represents a fixed timestamp gap between any two adjacent frames fed to the encoder. Note that this will also apply even when the original timestamp goes backward in time. Under normal conditions, such frames would be dropped and not sent to the encoder. The output timestamp will be restored to the original timestamp and will not be affected. This is used in some special scenarios where input frames arrive sparingly but it's undesirable to allocate more bits to any single frame, or when it's important to ensure all frames are captured (rather than captured in the correct order).
Value: "max-pts-gap-to-encoder"
KEY_MAX_WIDTH
static val KEY_MAX_WIDTH: String
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
Value: "max-width"
KEY_MIME
static val KEY_MIME: String
A key describing the mime type of the MediaFormat. The associated value is a string.
Value: "mime"
KEY_MPEGH_COMPATIBLE_SETS
static val KEY_MPEGH_COMPATIBLE_SETS: String
A key describing the MPEG-H stream compatible sets. See FDAmd_2 of ISO_IEC_23008-3;2019 MHAProfileAndLevelCompatibilitySetBox.
Value: "mpegh-compatible-sets"
KEY_MPEGH_PROFILE_LEVEL_INDICATION
static val KEY_MPEGH_PROFILE_LEVEL_INDICATION: String
A key describing the MPEG-H stream profile-level indication. See ISO_IEC_23008-3;2019 MHADecoderConfigurationRecord mpegh3daProfileLevelIndication.
Value: "mpegh-profile-level-indication"
KEY_MPEGH_REFERENCE_CHANNEL_LAYOUT
static val KEY_MPEGH_REFERENCE_CHANNEL_LAYOUT: String
A key describing the MPEG-H stream reference channel layout. See ISO_IEC_23008-3;2019 MHADecoderConfigurationRecord referenceChannelLayout and ISO_IEC_23001‐8 ChannelConfiguration value.
Value: "mpegh-reference-channel-layout"
KEY_OPERATING_RATE
static val KEY_OPERATING_RATE: String
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.
Value: "operating-rate"
KEY_OUTPUT_REORDER_DEPTH
static val KEY_OUTPUT_REORDER_DEPTH: String
An optional key describing the maximum number of non-display-order coded frames. This is an optional parameter that applies only to video encoders. Application should check the value for this key in the output format to see if codec will produce non-display-order coded frames. If encoder supports it, the output frames' order will be different from the display order and each frame's display order could be retrived from MediaCodec.BufferInfo#presentationTimeUs
. Before API level 27, application may receive non-display-order coded frames even though the application did not request it. Note: Application should not rearrange the frames to display order before feeding them to MediaMuxer#writeSampleData
.
The default value is 0.
Value: "output-reorder-depth"
KEY_PCM_ENCODING
static val KEY_PCM_ENCODING: String
A key describing the raw audio sample encoding/format.
The associated value is an integer, using one of the AudioFormat
.ENCODING_PCM_ values.
This is an optional key for audio decoders and encoders specifying the desired raw audio sample format during android.media.MediaCodec#configure call. Use MediaCodec.getInput
/android.media.MediaCodec#getOutputFormat to confirm the actual format. For the PCM decoder this key specifies both input and output sample encodings.
This key is also used by MediaExtractor
to specify the sample format of audio data, if it is specified.
If this key is missing, the raw audio sample format is signed 16-bit short.
Value: "pcm-encoding"
KEY_PICTURE_TYPE
static val KEY_PICTURE_TYPE: String
A key describing the picture type of the encoded frame. This is a part of a video 'Encoding Statistics' export feature. This value is emitted from video encoder for a video frame. The associated value is an integer.
Value: "picture-type"
KEY_PIXEL_ASPECT_RATIO_HEIGHT
static val KEY_PIXEL_ASPECT_RATIO_HEIGHT: String
A key describing the pixel aspect ratio height. The associated value is an integer
Value: "sar-height"
KEY_PIXEL_ASPECT_RATIO_WIDTH
static val KEY_PIXEL_ASPECT_RATIO_WIDTH: String
A key describing the pixel aspect ratio width. The associated value is an integer
Value: "sar-width"
KEY_PREPEND_HEADER_TO_SYNC_FRAMES
static val KEY_PREPEND_HEADER_TO_SYNC_FRAMES: String
An optional key describing whether encoders prepend headers to sync frames (e.g. SPS and PPS to IDR frames for H.264). This is an optional parameter that applies only to video encoders. A video encoder may not support this feature; the component will fail to configure in that case. For other components, this key is ignored. The value is an integer, with 1 indicating to prepend headers to every sync frames, or 0 otherwise. The default value is 0.
Value: "prepend-sps-pps-to-idr-frames"
KEY_PRIORITY
static val KEY_PRIORITY: String
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.
Value: "priority"
KEY_PROFILE
static val KEY_PROFILE: String
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. When configuring profile, encoder configuration may fail if other parameters are not compatible with the desired profile or if the desired profile is not supported, but it may also fail silently (where the encoder ends up using a different, compatible profile.)
It is recommended that the profile is set for all encoders. For more information, see the Encoder Profiles section of the MediaCodec
API reference.
Note: Codecs are free to use all the available coding tools at the specified profile, but may ultimately choose to not do so.
Note: When configuring video encoders, profile (if set) must be set together with level
.
Value: "profile"
KEY_PUSH_BLANK_BUFFERS_ON_STOP
static val KEY_PUSH_BLANK_BUFFERS_ON_STOP: String
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.
Value: "push-blank-buffers-on-shutdown"
KEY_QUALITY
static val KEY_QUALITY: String
A key describing the desired encoding quality. The associated value is an integer. This key is only supported for encoders that are configured in constant-quality mode. These values are device and codec specific, but lower values generally result in more efficient (smaller-sized) encoding.
Value: "quality"
KEY_REPEAT_PREVIOUS_FRAME_AFTER
static val KEY_REPEAT_PREVIOUS_FRAME_AFTER: String
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.
Value: "repeat-previous-frame-after"
KEY_ROTATION
static val KEY_ROTATION: String
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. Supported values are 0, 90, 180 or 270. This is an optional field; if not specified, rotation defaults to 0.
Value: "rotation-degrees"
KEY_SAMPLE_RATE
static val KEY_SAMPLE_RATE: String
A key describing the sample rate of an audio format. The associated value is an integer
Value: "sample-rate"
KEY_SLICE_HEIGHT
static val KEY_SLICE_HEIGHT: String
A key describing the plane height of a multi-planar (YUV) video bytebuffer layout. Slice height (or plane height/vertical stride) 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, though it is generally undefined and depends on the device and release. The associated value is an integer, representing number of rows.
Value: "slice-height"
KEY_SLOW_MOTION_MARKERS
static val KEY_SLOW_MOTION_MARKERS: String
A key for retrieving the slow-motion marker information associated with a video track.
The associated value is a ByteBuffer in ByteOrder#BIG_ENDIAN
(networking order) of the following format:
float(32) playbackRate; unsigned int(32) numMarkers; for (i = 0;i < numMarkers; i++) { int(64) timestampUs; float(32) speedRatio; }The meaning of each field is as follows:
playbackRate | The frame rate at which the playback should happen (or the flattened clip should be). |
numMarkers | The number of slow-motion markers that follows. |
timestampUs | The starting point of a new segment. |
speedRatio | The playback speed for that segment. The playback speed is a floating point number, indicating how fast the time progresses relative to that written in the container. (Eg. 4.0 means time goes 4x as fast, which makes 30fps become 120fps.) |
The following constraints apply to the timestampUs of the markers:
Value: "slow-motion-markers"
KEY_STRIDE
static val KEY_STRIDE: String
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, though it is generally undefined and depends on the device and release. The associated value is an integer, representing number of bytes.
Value: "stride"
KEY_TEMPORAL_LAYERING
static val KEY_TEMPORAL_LAYERING: String
A key describing the temporal layering schema. This is an optional parameter that applies only to video encoders. Use android.media.MediaCodec#getOutputFormat after android.media.MediaCodec#configure to query if the encoder supports the desired schema. Supported values are webrtc.vp8.N-layer
, android.generic.N
, android.generic.N+M
and none
, where N
denotes the total number of non-bidirectional layers (which must be at least 1) and M
denotes the total number of bidirectional layers (which must be non-negative).
android.generic.*
schemas have been added in android.os.Build.VERSION_CODES#N_MR1
.
The encoder may support fewer temporal layers, in which case the output format will contain the configured schema. If the encoder does not support temporal layering, the output format will not have an entry with this key. The associated value is a string.
Value: "ts-schema"
KEY_TILE_HEIGHT
static val KEY_TILE_HEIGHT: String
A key describing the height (in pixels) of each tile of the content in a MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
track. The associated value is an integer. Refer to MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
on decoding instructions of such tracks.
Value: "tile-height"
KEY_TILE_WIDTH
static val KEY_TILE_WIDTH: String
A key describing the width (in pixels) of each tile of the content in a MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
track. The associated value is an integer. Refer to MIMETYPE_IMAGE_ANDROID_HEIC
/ MIMETYPE_IMAGE_AVIF
on decoding instructions of such tracks.
Value: "tile-width"
KEY_TRACK_ID
static val KEY_TRACK_ID: String
A key describing a unique ID for the content of a media track.
This key is used by MediaExtractor
. Some extractors provide multiple encodings of the same track (e.g. float audio tracks for FLAC and WAV may be expressed as two tracks via MediaExtractor: a normal PCM track for backward compatibility, and a float PCM track for added fidelity. Similarly, Dolby Vision extractor may provide a baseline SDR version of a DV track.) This key can be used to identify which MediaExtractor tracks refer to the same underlying content.
Value: "track-id"
KEY_VIDEO_ENCODING_STATISTICS_LEVEL
static val KEY_VIDEO_ENCODING_STATISTICS_LEVEL: String
A key describing the level of encoding statistics information emitted from video encoder. The associated value is an integer.
Value: "video-encoding-statistics-level"
KEY_VIDEO_QP_AVERAGE
static val KEY_VIDEO_QP_AVERAGE: String
A key describing the per-frame average block QP (Quantization Parameter). This is a part of a video 'Encoding Statistics' export feature. This value is emitted from video encoder for a video frame. The average value is rounded to the nearest integer value. The associated value is an integer.
Value: "video-qp-average"
KEY_VIDEO_QP_B_MAX
static val KEY_VIDEO_QP_B_MAX: String
A key describing the maximum Quantization Parameter allowed for encoding video. This value applies to video B-frames. The associated value is an integer.
Value: "video-qp-b-max"
KEY_VIDEO_QP_B_MIN
static val KEY_VIDEO_QP_B_MIN: String
A key describing the minimum Quantization Parameter allowed for encoding video. This value applies to video B-frames. The associated value is an integer.
Value: "video-qp-b-min"
KEY_VIDEO_QP_I_MAX
static val KEY_VIDEO_QP_I_MAX: String
A key describing the maximum Quantization Parameter allowed for encoding video. This value applies to video I-frames. The associated value is an integer.
Value: "video-qp-i-max"
KEY_VIDEO_QP_I_MIN
static val KEY_VIDEO_QP_I_MIN: String
A key describing the minimum Quantization Parameter allowed for encoding video. This value applies to video I-frames. The associated value is an integer.
Value: "video-qp-i-min"
KEY_VIDEO_QP_MAX
static val KEY_VIDEO_QP_MAX: String
A key describing the maximum Quantization Parameter allowed for encoding video. This key applies to all three video picture types (I, P, and B). The value is used directly for picture type I; a per-mime formula is used to calculate the value for the remaining picture types. This calculation can be avoided by directly specifying values for each picture type using the type-specific keys KEY_VIDEO_QP_I_MAX
, KEY_VIDEO_QP_P_MAX
, and KEY_VIDEO_QP_B_MAX
. The associated value is an integer.
Value: "video-qp-max"
KEY_VIDEO_QP_MIN
static val KEY_VIDEO_QP_MIN: String
A key describing the minimum Quantization Parameter allowed for encoding video. This key applies to all three video frame types (I, P, and B). The value is used directly for picture type I; a per-mime formula is used to calculate the value for the remaining picture types. This calculation can be avoided by directly specifying values for each picture type using the type-specific keys KEY_VIDEO_QP_I_MIN
, KEY_VIDEO_QP_P_MIN
, and KEY_VIDEO_QP_B_MIN
. The associated value is an integer.
Value: "video-qp-min"
KEY_VIDEO_QP_P_MAX
static val KEY_VIDEO_QP_P_MAX: String
A key describing the maximum Quantization Parameter allowed for encoding video. This value applies to video P-frames. The associated value is an integer.
Value: "video-qp-p-max"
KEY_VIDEO_QP_P_MIN
static val KEY_VIDEO_QP_P_MIN: String
A key describing the minimum Quantization Parameter allowed for encoding video. This value applies to video P-frames. The associated value is an integer.
Value: "video-qp-p-min"
KEY_WIDTH
static val KEY_WIDTH: String
A key describing the width of the content in a video format. The associated value is an integer
Value: "width"
LOG_SESSION_ID
static val LOG_SESSION_ID: String
A key describing the log session ID for MediaCodec. The log session ID is a random 32-byte hexadecimal string that is used to associate metrics from multiple media codec instances to the same playback or recording session. The value is created as LogSessionId
. Sessions are created in MediaMetricsManager
. The associated value is a string.
Value: "log-session-id"
MIMETYPE_AUDIO_AAC
static val MIMETYPE_AUDIO_AAC: String
Value: "audio/mp4a-latm"
MIMETYPE_AUDIO_AAC_ELD
static val MIMETYPE_AUDIO_AAC_ELD: String
MIME type for AAC Enhanced Low Delay (ELD) audio stream. Uses the scheme defined by RFC 6381 with OTI of MPEG-4 (40) and AOT of ELD (39) from ISO/IEC 14496-3.
Value: "audio/mp4a.40.39"
MIMETYPE_AUDIO_AAC_HE_V1
static val MIMETYPE_AUDIO_AAC_HE_V1: String
MIME type for HE-AAC v1 (LC + SBR) audio stream. Uses the scheme defined by RFC 6381 with OTI of MPEG-4 (40) and AOT of AAC SBR (5) from ISO/IEC 14496-3.
Value: "audio/mp4a.40.05"
MIMETYPE_AUDIO_AAC_HE_V2
static val MIMETYPE_AUDIO_AAC_HE_V2: String
MIME type for HE-AAC v2 (LC + SBR + PS) audio stream. Uses the scheme defined by RFC 6381 with OTI of MPEG-4 (40) and AOT of PS (29) from ISO/IEC 14496-3.
Value: "audio/mp4a.40.29"
MIMETYPE_AUDIO_AAC_LC
static val MIMETYPE_AUDIO_AAC_LC: String
MIME type for AAC Low Complexity (LC) audio stream. Uses the scheme defined by RFC 6381 with OTI of MPEG-4 (40) and AOT of AAC LC (2) from ISO/IEC 14496-3.
Value: "audio/mp4a.40.02"
MIMETYPE_AUDIO_AAC_XHE
static val MIMETYPE_AUDIO_AAC_XHE: String
MIME type for AAC XHE audio stream. Uses the scheme defined by RFC 6381 with OTI of MPEG-4 (40) and AOT of USAC (42) from ISO/IEC 14496-3.
Value: "audio/mp4a.40.42"
MIMETYPE_AUDIO_AMR_NB
static val MIMETYPE_AUDIO_AMR_NB: String
Value: "audio/3gpp"
MIMETYPE_AUDIO_AMR_WB
static val MIMETYPE_AUDIO_AMR_WB: String
Value: "audio/amr-wb"
MIMETYPE_AUDIO_DOLBY_MAT
static val MIMETYPE_AUDIO_DOLBY_MAT: String
MIME type for Dolby Metadata-enhanced Audio Transmission (MAT) audio stream.
Value: "audio/vnd.dolby.mat"
MIMETYPE_AUDIO_DOLBY_TRUEHD
static val MIMETYPE_AUDIO_DOLBY_TRUEHD: String
MIME type for Dolby TrueHD audio format, based on Meridian Lossless Packing (MLP).
Value: "audio/vnd.dolby.mlp"
MIMETYPE_AUDIO_DRA
static val MIMETYPE_AUDIO_DRA: String
MIME type for Dynamic Resolution Adaptation (DRA) audio stream.
Value: "audio/vnd.dra"
MIMETYPE_AUDIO_DTS
static val MIMETYPE_AUDIO_DTS: String
MIME type for DTS Digital Surround (up to 5.1 channels) audio stream, aka DTS-CA.
Value: "audio/vnd.dts"
MIMETYPE_AUDIO_DTS_HD
static val MIMETYPE_AUDIO_DTS_HD: String
MIME type for DTS HD (up to 7.1 channels) audio stream. With codec profile DTS_HDProfileHRA represents DTS HD High Resolution Audio. With codec profile DTS_HDProfileMA represents DTS HD Master Audio. With codec profile DTS_HDProfileLBR represents DTS Express.
Value: "audio/vnd.dts.hd"
MIMETYPE_AUDIO_DTS_UHD
static val MIMETYPE_AUDIO_DTS_UHD: String
MIME type for DTS UHD (object-based) audio stream, aka DTS:X. With codec profile DTS_UHDProfileP1 represents DTS-UHD P1. With codec profile DTS_UHDProfileP2 represents DTS-UHD P2.
Value: "audio/vnd.dts.uhd"
MIMETYPE_AUDIO_EAC3
static val MIMETYPE_AUDIO_EAC3: String
Value: "audio/eac3"
MIMETYPE_AUDIO_EAC3_JOC
static val MIMETYPE_AUDIO_EAC3_JOC: String
Value: "audio/eac3-joc"
MIMETYPE_AUDIO_FLAC
static val MIMETYPE_AUDIO_FLAC: String
Value: "audio/flac"
MIMETYPE_AUDIO_G711_ALAW
static val MIMETYPE_AUDIO_G711_ALAW: String
Value: "audio/g711-alaw"
MIMETYPE_AUDIO_G711_MLAW
static val MIMETYPE_AUDIO_G711_MLAW: String
Value: "audio/g711-mlaw"
MIMETYPE_AUDIO_IEC61937
static val MIMETYPE_AUDIO_IEC61937: String
MIME type for the IEC61937 audio stream encapsulation. This type isn't defined by IANA.
Value: "audio/x-iec61937"
MIMETYPE_AUDIO_MPEG
static val MIMETYPE_AUDIO_MPEG: String
Value: "audio/mpeg"
MIMETYPE_AUDIO_MPEGH_BL_L3
static val MIMETYPE_AUDIO_MPEGH_BL_L3: String
MIME type for MPEG-H Baseline (BL) Profile L3 audio stream. Uses the scheme defined by RFC 6381 with mpegh3daProfileLevelIndication for main profile/L3 (0x3) from ISO/IEC 23008-3.
Value: "audio/mhm1.03"
MIMETYPE_AUDIO_MPEGH_BL_L4
static val MIMETYPE_AUDIO_MPEGH_BL_L4: String
MIME type for MPEG-H Baseline (BL) Profile L4 audio stream. Uses the scheme defined by RFC 6381 with mpegh3daProfileLevelIndication for main profile/L4 (0x4) from ISO/IEC 23008-3.
Value: "audio/mhm1.04"
MIMETYPE_AUDIO_MPEGH_LC_L3
static val MIMETYPE_AUDIO_MPEGH_LC_L3: String
MIME type for MPEG-H Low Complexity (LC) L3 audio stream. Uses the scheme defined by RFC 6381 with mpegh3daProfileLevelIndication for LC profile/L3 (0xD) from ISO/IEC 23008-3.
Value: "audio/mhm1.0d"
MIMETYPE_AUDIO_MPEGH_LC_L4
static val MIMETYPE_AUDIO_MPEGH_LC_L4: String
MIME type for MPEG-H Low Complexity (LC) L4 audio stream. Uses the scheme defined by RFC 6381 with mpegh3daProfileLevelIndication for LC profile/L4 (0xE) from ISO/IEC 23008-3.
Value: "audio/mhm1.0e"
MIMETYPE_AUDIO_MPEGH_MHA1
static val MIMETYPE_AUDIO_MPEGH_MHA1: String
MIME type for MPEG-H Audio single stream
Value: "audio/mha1"
MIMETYPE_AUDIO_MPEGH_MHM1
static val MIMETYPE_AUDIO_MPEGH_MHM1: String
MIME type for MPEG-H Audio single stream, encapsulated in MHAS
Value: "audio/mhm1"
MIMETYPE_AUDIO_MSGSM
static val MIMETYPE_AUDIO_MSGSM: String
Value: "audio/gsm"
MIMETYPE_AUDIO_OPUS
static val MIMETYPE_AUDIO_OPUS: String
Value: "audio/opus"
MIMETYPE_AUDIO_QCELP
static val MIMETYPE_AUDIO_QCELP: String
Value: "audio/qcelp"
MIMETYPE_AUDIO_SCRAMBLED
static val MIMETYPE_AUDIO_SCRAMBLED: String
Value: "audio/scrambled"
MIMETYPE_AUDIO_VORBIS
static val MIMETYPE_AUDIO_VORBIS: String
Value: "audio/vorbis"
MIMETYPE_IMAGE_ANDROID_HEIC
static val MIMETYPE_IMAGE_ANDROID_HEIC: String
MIME type for HEIF still image data encoded in HEVC. To decode such an image, MediaCodec
decoder for MIMETYPE_VIDEO_HEVC
shall be used. The client needs to form the correct #MediaFormat based on additional information in the track format (shown in the next paragraph), and send it to android.media.MediaCodec#configure. The track's MediaFormat will come with KEY_WIDTH
and KEY_HEIGHT
keys, which describes the width and height of the image. If the image doesn't contain grid (i.e. none of KEY_TILE_WIDTH
, KEY_TILE_HEIGHT
, KEY_GRID_ROWS
, KEY_GRID_COLUMNS
are present), the track will contain a single sample of coded data for the entire image, and the image width and height should be used to set up the decoder. If the image does come with grid, each sample from the track will contain one tile in the grid, of which the size is described by KEY_TILE_WIDTH
and KEY_TILE_HEIGHT
. This size (instead of KEY_WIDTH
and KEY_HEIGHT
) should be used to set up the decoder. The track contains KEY_GRID_ROWS
by KEY_GRID_COLUMNS
samples in row-major, top-row first, left-to-right order. The output image should be reconstructed by first tiling the decoding results of the tiles in the correct order, then trimming (before rotation is applied) on the bottom and right side, if the tiled area is larger than the image width and height.
Value: "image/vnd.android.heic"
MIMETYPE_IMAGE_AVIF
static val MIMETYPE_IMAGE_AVIF: String
MIME type for AVIF still image data encoded in AV1. To decode such an image, MediaCodec
decoder for MIMETYPE_VIDEO_AV1
shall be used. The client needs to form the correct #MediaFormat based on additional information in the track format (shown in the next paragraph), and send it to android.media.MediaCodec#configure. The track's MediaFormat will come with KEY_WIDTH
and KEY_HEIGHT
keys, which describes the width and height of the image. If the image doesn't contain grid (i.e. none of KEY_TILE_WIDTH
, KEY_TILE_HEIGHT
, KEY_GRID_ROWS
, KEY_GRID_COLUMNS
are present), the track will contain a single sample of coded data for the entire image, and the image width and height should be used to set up the decoder. If the image does come with grid, each sample from the track will contain one tile in the grid, of which the size is described by KEY_TILE_WIDTH
and KEY_TILE_HEIGHT
. This size (instead of KEY_WIDTH
and KEY_HEIGHT
) should be used to set up the decoder. The track contains KEY_GRID_ROWS
by KEY_GRID_COLUMNS
samples in row-major, top-row first, left-to-right order. The output image should be reconstructed by first tiling the decoding results of the tiles in the correct order, then trimming (before rotation is applied) on the bottom and right side, if the tiled area is larger than the image width and height.
Value: "image/avif"
MIMETYPE_TEXT_CEA_608
static val MIMETYPE_TEXT_CEA_608: String
MIME type for CEA-608 closed caption data.
Value: "text/cea-608"
MIMETYPE_TEXT_CEA_708
static val MIMETYPE_TEXT_CEA_708: String
MIME type for CEA-708 closed caption data.
Value: "text/cea-708"
MIMETYPE_TEXT_SUBRIP
static val MIMETYPE_TEXT_SUBRIP: String
MIME type for SubRip (SRT) container.
Value: "application/x-subrip"
MIMETYPE_TEXT_VTT
static val MIMETYPE_TEXT_VTT: String
MIME type for WebVTT subtitle data.
Value: "text/vtt"
MIMETYPE_VIDEO_DOLBY_VISION
static val MIMETYPE_VIDEO_DOLBY_VISION: String
Value: "video/dolby-vision"
MIMETYPE_VIDEO_H263
static val MIMETYPE_VIDEO_H263: String
Value: "video/3gpp"
MIMETYPE_VIDEO_HEVC
static val MIMETYPE_VIDEO_HEVC: String
Value: "video/hevc"
MIMETYPE_VIDEO_MPEG2
static val MIMETYPE_VIDEO_MPEG2: String
Value: "video/mpeg2"
MIMETYPE_VIDEO_MPEG4
static val MIMETYPE_VIDEO_MPEG4: String
Value: "video/mp4v-es"
MIMETYPE_VIDEO_SCRAMBLED
static val MIMETYPE_VIDEO_SCRAMBLED: String
Value: "video/scrambled"
MIMETYPE_VIDEO_VP8
static val MIMETYPE_VIDEO_VP8: String
Value: "video/x-vnd.on2.vp8"
MIMETYPE_VIDEO_VP9
static val MIMETYPE_VIDEO_VP9: String
Value: "video/x-vnd.on2.vp9"
PICTURE_TYPE_B
static val PICTURE_TYPE_B: Int
Picture Type is B Frame.
Value: 3
PICTURE_TYPE_I
static val PICTURE_TYPE_I: Int
Picture Type is I Frame.
Value: 1
PICTURE_TYPE_P
static val PICTURE_TYPE_P: Int
Picture Type is P Frame.
Value: 2
PICTURE_TYPE_UNKNOWN
static val PICTURE_TYPE_UNKNOWN: Int
Picture Type is unknown.
Value: 0
VIDEO_ENCODING_STATISTICS_LEVEL_1
static val VIDEO_ENCODING_STATISTICS_LEVEL_1: Int
Encoding Statistics Level 1. Encoder generates MediaFormat#KEY_PICTURE_TYPE
and MediaFormat#KEY_VIDEO_QP_AVERAGE
for each frame.
Value: 1
VIDEO_ENCODING_STATISTICS_LEVEL_NONE
static val VIDEO_ENCODING_STATISTICS_LEVEL_NONE: Int
Encoding Statistics Level None. Encoder generates no information about Encoding statistics.
Value: 0
Public constructors
MediaFormat
MediaFormat(other: MediaFormat)
Create a copy of a media format object.
Parameters | |
---|---|
other |
MediaFormat: This value cannot be null . |
Public methods
containsFeature
fun containsFeature(name: String): Boolean
Returns true iff a feature of the given name exists in the format.
Parameters | |
---|---|
name |
String: This value cannot be null . |
containsKey
fun containsKey(name: String): Boolean
Returns true iff a key of the given name exists in the format.
Parameters | |
---|---|
name |
String: This value cannot be null . |
createAudioFormat
static fun createAudioFormat(
mime: String,
sampleRate: Int,
channelCount: Int
): MediaFormat
Creates a minimal audio format.
Parameters | |
---|---|
mime |
String: The mime type of the content. This value cannot be null . |
sampleRate |
Int: The sampling rate of the content. |
channelCount |
Int: The number of audio channels in the content. |
Return | |
---|---|
MediaFormat |
This value cannot be null . |
createSubtitleFormat
static fun createSubtitleFormat(
mime: String,
language: String!
): MediaFormat
Creates a minimal subtitle format.
Parameters | |
---|---|
mime |
String: The mime type of the content. This value cannot be null . |
language |
String!: 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.) |
Return | |
---|---|
MediaFormat |
This value cannot be null . |
createVideoFormat
static fun createVideoFormat(
mime: String,
width: Int,
height: Int
): MediaFormat
Creates a minimal video format.
Parameters | |
---|---|
mime |
String: The mime type of the content. This value cannot be null . |
width |
Int: The width of the content (in pixels) |
height |
Int: The height of the content (in pixels) |
Return | |
---|---|
MediaFormat |
This value cannot be null . |
getByteBuffer
fun getByteBuffer(name: String): ByteBuffer?
Returns the value of a ByteBuffer key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Return | |
---|---|
ByteBuffer? |
null if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is int, long, float or String |
getByteBuffer
fun getByteBuffer(
name: String,
defaultValue: ByteBuffer
): ByteBuffer
Returns the value of a ByteBuffer key, or the default value if the key is missing.
Parameters | |
---|---|
name |
String: This value cannot be null . |
defaultValue |
ByteBuffer: This value cannot be null . |
Return | |
---|---|
ByteBuffer |
defaultValue if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is int, long, float or String |
getFeatureEnabled
fun getFeatureEnabled(feature: String): Boolean
Returns whether a feature is to be enabled (true
) or disabled (false
).
Parameters | |
---|---|
feature |
String: the name of a MediaCodecInfo.CodecCapabilities feature. This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the feature was neither set to be enabled nor to be disabled. |
getFeatures
fun getFeatures(): MutableSet<String!>
Returns a Set
view of the features contained in this MediaFormat. The set is backed by the MediaFormat object, so changes to the format are reflected in the set, and vice-versa. If the format is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the format, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
Return | |
---|---|
MutableSet<String!> |
This value cannot be null . |
getFloat
fun getFloat(name: String): Float
Returns the value of a float key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the key does not exist or the stored value for the key is null |
java.lang.ClassCastException |
if the stored value for the key is int, long, ByteBuffer or String |
getFloat
fun getFloat(
name: String,
defaultValue: Float
): Float
Returns the value of a float key, or the default value if the key is missing.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Return | |
---|---|
Float |
defaultValue if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is int, long, ByteBuffer or String |
getInteger
fun getInteger(name: String): Int
Returns the value of an integer key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the key does not exist or the stored value for the key is null |
java.lang.ClassCastException |
if the stored value for the key is long, float, ByteBuffer or String |
getInteger
fun getInteger(
name: String,
defaultValue: Int
): Int
Returns the value of an integer key, or the default value if the key is missing.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Return | |
---|---|
Int |
defaultValue if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is long, float, ByteBuffer or String |
getKeys
fun getKeys(): MutableSet<String!>
Returns a Set
view of the keys contained in this MediaFormat. The set is backed by the MediaFormat object, so changes to the format are reflected in the set, and vice-versa. If the format is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the format, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
Return | |
---|---|
MutableSet<String!> |
This value cannot be null . |
getLong
fun getLong(name: String): Long
Returns the value of a long key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the key does not exist or the stored value for the key is null |
java.lang.ClassCastException |
if the stored value for the key is int, float, ByteBuffer or String |
getLong
fun getLong(
name: String,
defaultValue: Long
): Long
Returns the value of a long key, or the default value if the key is missing.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Return | |
---|---|
Long |
defaultValue if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is int, float, ByteBuffer or String |
getNumber
fun getNumber(name: String): Number?
Returns the value of a numeric key. This is provided as a convenience method for keys that may take multiple numeric types, such as KEY_FRAME_RATE
, or KEY_I_FRAME_INTERVAL
.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Return | |
---|---|
Number? |
null if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is ByteBuffer or String |
getNumber
fun getNumber(
name: String,
defaultValue: Number
): Number
Returns the value of a numeric key, or the default value if the key is missing.
Parameters | |
---|---|
name |
String: This value cannot be null . |
defaultValue |
Number: This value cannot be null . |
Return | |
---|---|
Number |
defaultValue if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is ByteBuffer or String |
getString
fun getString(name: String): String?
Returns the value of a string key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
Return | |
---|---|
String? |
null if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is int, long, float or ByteBuffer |
getString
fun getString(
name: String,
defaultValue: String
): String
Returns the value of a string key, or the default value if the key is missing.
Parameters | |
---|---|
name |
String: This value cannot be null . |
defaultValue |
String: This value cannot be null . |
Return | |
---|---|
String |
defaultValue if the key does not exist or the stored value for the key is null |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the stored value for the key is int, long, float or ByteBuffer |
getValueTypeForKey
fun getValueTypeForKey(name: String): Int
Returns the value type for a key. If the key does not exist, it returns TYPE_NULL.
Parameters | |
---|---|
name |
String: This value cannot be null . |
removeFeature
fun removeFeature(name: String): Unit
Removes a given feature setting if present. Has no effect if the feature setting is not present.
Parameters | |
---|---|
name |
String: This value cannot be null . |
removeKey
fun removeKey(name: String): Unit
Removes a value of a given key if present. Has no effect if the key is not present.
Parameters | |
---|---|
name |
String: This value cannot be null . |
setByteBuffer
fun setByteBuffer(
name: String,
bytes: ByteBuffer?
): Unit
Sets the value of a ByteBuffer key.
If value is null
, it sets a null value that behaves similarly to a missing key. This could be used prior to API level os.Build.VERSION_CODES#Q
to effectively remove a key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
bytes |
ByteBuffer?: This value may be null . |
setFeatureEnabled
fun setFeatureEnabled(
feature: String,
enabled: Boolean
): Unit
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 |
String: the name of a MediaCodecInfo.CodecCapabilities feature. This value cannot be null . |
setFloat
fun setFloat(
name: String,
value: Float
): Unit
Sets the value of a float key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
setInteger
fun setInteger(
name: String,
value: Int
): Unit
Sets the value of an integer key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
setLong
fun setLong(
name: String,
value: Long
): Unit
Sets the value of a long key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
setString
fun setString(
name: String,
value: String?
): Unit
Sets the value of a string key.
If value is null
, it sets a null value that behaves similarly to a missing key. This could be used prior to API level os.Build.VERSION_CODES#Q
to effectively remove a key.
Parameters | |
---|---|
name |
String: This value cannot be null . |
value |
String?: This value may be null . |
toString
fun toString(): String
Returns a string representation of the object.
Return | |
---|---|
String |
This value cannot be null . |