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 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 | encoder-only |
KEY_FRAME_RATE | Integer or Float | encoder-only |
KEY_I_FRAME_INTERVAL | Integer | encoder-only |
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. |
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_I_FRAME_INTERVAL | A key describing the frequency of I frames expressed in secs between I frames. | |||||||||
String | KEY_MAX_INPUT_SIZE | A key describing the maximum size in bytes of a buffer of data described by this MediaFormat. | |||||||||
String | KEY_MIME | A key describing the mime type of the MediaFormat. | |||||||||
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 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.CodecCapabilities
.
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 describing the frequency of I frames expressed in secs between I frames. 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 mime type of the MediaFormat. The associated value is a string.
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 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.