java.lang.Object | |
↳ | android.media.MediaFormat |
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 :
Name | Value Type | Description |
---|---|---|
KEY_MIME
|
String | The type of the format. |
KEY_MAX_INPUT_SIZE
|
Integer | optional, maximum size of a buffer of input data |
KEY_BIT_RATE
|
Integer | encoder-only , desired bitrate in bits/second |
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 | encoder-only |
KEY_I_FRAME_INTERVAL
|
Integer | encoder-only |
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 | video encoder in surface-mode only |
KEY_PUSH_BLANK_BUFFERS_ON_STOP
|
Integer(1) | video decoder rendering to a surface only |
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.
Name | Value Type | Description |
---|---|---|
KEY_CHANNEL_COUNT
|
Integer | |
KEY_SAMPLE_RATE
|
Integer | |
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_CHANNEL_MASK
|
Integer | optional, a mask of audio channel assignments |
KEY_FLAC_COMPRESSION_LEVEL
|
Integer | encoder-only , optional, if content is FLAC audio, specifies the desired compression level. |
KEY_MIME
|
String | The type of the format. |
KEY_LANGUAGE
|
String | The language of the content. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | KEY_AAC_PROFILE | A key describing the AAC profile to be used (AAC audio formats only). | |||||||||
String | KEY_BIT_RATE | A key describing the bitrate in bits/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_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_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_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_SAMPLE_RATE | A key describing the sample rate of an audio format. | |||||||||
String | KEY_WIDTH | A key describing the width of the content in a video format. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Creates an empty MediaFormat
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Returns true iff a key of the given name exists in the format.
|
||||||||||
|
Creates a minimal audio format.
|
||||||||||
|
Creates a minimal subtitle format.
|
||||||||||
|
Creates a minimal video format.
|
||||||||||
|
Returns the value of a ByteBuffer key.
|
||||||||||
|
Returns the value of a float key.
|
||||||||||
|
Returns the value of an integer key.
|
||||||||||
|
Returns the value of a long key.
|
||||||||||
|
Returns the value of a string key.
|
||||||||||
|
Sets the value of a ByteBuffer key.
|
||||||||||
|
Sets the value of a float key.
|
||||||||||
|
Sets the value of an integer key.
|
||||||||||
|
Sets the value of a long key.
|
||||||||||
|
Sets the value of a string key.
|
||||||||||
|
Returns a string containing a concise, human-readable description of this
object.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
A key describing the AAC profile to be used (AAC audio formats only).
Constants are declared in
MediaCodecInfo.CodecProfileLevel
.
A key describing the bitrate in bits/sec. The associated value is an integer
A key describing the number of channels in an audio format. The associated value is an integer
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.
A key describing the color format of the content in a video format.
Constants are declared in
MediaCodecInfo.CodecCapabilities
.
A key describing the duration (in microseconds) of the content. The associated value is a long.
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).
A key describing the frame rate of a video format in frames/sec. The associated value is an integer or a float.
A key describing the height of the content in a video format. The associated value is an integer
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.
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.
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.
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.
A key describing the frequency of I frames expressed in secs between I frames. The associated value is an integer.
A key describing the language of the content, using either ISO 639-1 or 639-2/T codes. The associated value is a 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
A key describing the maximum size in bytes of a buffer of data described by this MediaFormat. The associated value is an integer
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
A key describing the mime type of the MediaFormat. The associated value is a 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.
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.
A key describing the sample rate of an audio format. The associated value is an integer
A key describing the width of the content in a video format. The associated value is an integer
Returns true iff a key of the given name exists in the format.
Creates a minimal audio format.
mime | The mime type of the content. |
---|---|
sampleRate | The sampling rate of the content. |
channelCount | The number of audio channels in the content. |
Creates a minimal subtitle format.
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.) |
Creates a minimal video format.
mime | The mime type of the content. |
---|---|
width | The width of the content (in pixels) |
height | The height of the content (in pixels) |
Returns the value of a ByteBuffer key.
Returns the value of an integer key.
Returns the value of a string key.
Sets the value of a ByteBuffer key.
Sets the value of a float key.
Sets the value of an integer key.
Sets the value of a long key.
Sets the value of a string key.
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.