Android Guides | Samples

Android.Media.MediaFormat Class

Encapsulates the information describing the format of media data, be it audio or video.

See Also: MediaFormat

Syntax

[Android.Runtime.Register("android/media/MediaFormat", DoNotGenerateAcw=true)]
public sealed class MediaFormat : Object

Remarks

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

NameValue TypeDescription
MediaFormat.KeyMimeStringThe type of the format.
MediaFormat.KeyMaxInputSizeIntegeroptional, maximum size of a buffer of input data
MediaFormat.KeyBitRateIntegerencoder-only, desired bitrate in bits/second
Video formats have the following keys:
NameValue TypeDescription
MediaFormat.KeyWidthInteger
MediaFormat.KeyHeightInteger
MediaFormat.KeyColorFormatIntegerset by the user for encoders, readable in the output format of decoders
MediaFormat.KeyFrameRateInteger or Floatencoder-only
MediaFormat.KeyCaptureRateInteger
MediaFormat.KeyIFrameIntervalIntegerencoder-only
MediaFormat.KeyMaxWidthIntegerdecoder-only, optional, max-resolution width
MediaFormat.KeyMaxHeightIntegerdecoder-only, optional, max-resolution height
MediaFormat.KeyRepeatPreviousFrameAfterLongvideo encoder in surface-mode only
MediaFormat.KeyPushBlankBuffersOnStopInteger(1)video decoder rendering to a surface only
Specify both MediaFormat.KeyMaxWidth and MediaFormat.KeyMaxHeight to enable adaptive playback (seamless resolution change) for a video decoder that supports it (NoType:android/media/MediaCodecInfo$CodecCapabilities;Href=../../../reference/android/media/MediaCodecInfo.CodecCapabilities.html#FEATURE_AdaptivePlayback). The values are used as hints for the codec: they are the maximum expected resolution to prepare for. Depending on codec support, preparing for larger maximum resolution may require more memory even if that resolution is never reached. These fields have no effect for codecs that do not support adaptive playback.

Audio formats have the following keys:
NameValue TypeDescription
MediaFormat.KeyChannelCountInteger
MediaFormat.KeySampleRateInteger
MediaFormat.KeyIsAdtsIntegeroptional, if decoding AAC audio content, setting this key to 1 indicates that each audio frame is prefixed by the ADTS header.
MediaFormat.KeyAacProfileIntegerencoder-only, optional, if content is AAC audio, specifies the desired profile.
MediaFormat.KeyAacSbrModeIntegerencoder-only, optional, if content is AAC audio, specifies the desired SBR mode.
MediaFormat.KeyAacDrcTargetReferenceLevelIntegerdecoder-only, optional, if content is AAC audio, specifies the target reference level.
MediaFormat.KeyAacEncodedTargetLevelIntegerdecoder-only, optional, if content is AAC audio, specifies the target reference level used at encoder.
MediaFormat.KeyAacDrcBoostFactorIntegerdecoder-only, optional, if content is AAC audio, specifies the DRC boost factor.
MediaFormat.KeyAacDrcAttenuationFactorIntegerdecoder-only, optional, if content is AAC audio, specifies the DRC attenuation factor.
MediaFormat.KeyAacDrcHeavyCompressionIntegerdecoder-only, optional, if content is AAC audio, specifies whether to use heavy compression.
MediaFormat.KeyAacMaxOutputChannelCountIntegerdecoder-only, optional, if content is AAC audio, specifies the maximum number of channels the decoder outputs.
MediaFormat.KeyChannelMaskIntegeroptional, a mask of audio channel assignments
MediaFormat.KeyFlacCompressionLevelIntegerencoder-only, optional, if content is FLAC audio, specifies the desired compression level.
Subtitle formats have the following keys:
MediaFormat.KeyMimeStringThe type of the format.
MediaFormat.KeyLanguageStringThe language of the content.

[Android Documentation]

Requirements

Namespace: Android.Media
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 16

The members of Android.Media.MediaFormat are listed below.

See Also: Object

Public Constructors

Creates an empty MediaFormat

Public Fields

const
KeyAacDrcAttenuationFactorString. A key describing the attenuation factor allowing to adapt the dynamics of the output to the actual listening requirements.
const
KeyAacDrcBoostFactorString. A key describing the boost factor allowing to adapt the dynamics of the output to the actual listening requirements.
const
KeyAacDrcHeavyCompressionString. A key describing the selection of the heavy compression profile for DRC.
const
KeyAacDrcTargetReferenceLevelString. A key describing a gain to be applied so that the output loudness matches the Target Reference Level.
const
KeyAacEncodedTargetLevelString. A key describing the target reference level that was assumed at the encoder for calculation of attenuation gains for clipping prevention.
const
KeyAacMaxOutputChannelCountString. A key describing the maximum number of channels that can be output by the AAC decoder.
const
KeyAacProfileString. A key describing the AAC profile to be used (AAC audio formats only).
const
KeyAacSbrModeString. A key describing the AAC SBR mode to be used (AAC audio formats only).
const
KeyAudioSessionIdString. A key describing the audio session ID of the AudioTrack associated to a tunneled video codec.
const
KeyBitRateString. A key describing the bitrate in bits/sec.
const
KeyBitrateModeString. A key describing the desired bitrate mode to be used by an encoder.
const
KeyCaptureRateString. A key describing the capture rate of a video format in frames/sec.
const
KeyChannelCountString. A key describing the number of channels in an audio format.
const
KeyChannelMaskString. A key describing the channel composition of audio content.
const
KeyColorFormatString. A key describing the color format of the content in a video format.
const
KeyComplexityString. A key describing the encoding complexity.
const
KeyDurationString. A key describing the duration (in microseconds) of the content.
const
KeyFlacCompressionLevelString. A key describing the FLAC compression level to be used (FLAC audio format only).
const
KeyFrameRateString. A key describing the frame rate of a video format in frames/sec.
const
KeyHeightString. A key describing the height of the content in a video format.
const
KeyIFrameIntervalString. A key describing the frequency of I frames expressed in secs between I frames.
const
KeyIsAdtsString. A key mapping to a value of 1 if the content is AAC audio and audio frames are prefixed with an ADTS header.
const
KeyIsAutoselectString. A key for boolean AUTOSELECT behavior for the track.
const
KeyIsDefaultString. A key for boolean DEFAULT behavior for the track.
const
KeyIsForcedSubtitleString. A key for the FORCED field for subtitle tracks.
const
KeyLanguageString. A key describing the language of the content, using either ISO 639-1 or 639-2/T codes.
const
KeyMaxHeightString. 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.
const
KeyMaxInputSizeString. A key describing the maximum size in bytes of a buffer of data described by this MediaFormat.
const
KeyMaxWidthString. 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.
const
KeyMimeString. A key describing the mime type of the MediaFormat.
const
KeyProfileString. A key describing the desired profile to be used by an encoder.
const
KeyPushBlankBuffersOnStopString. 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.
const
KeyRepeatPreviousFrameAfterString. Applies only when configuring a video encoder in "surface-input" mode.
const
KeySampleRateString. A key describing the sample rate of an audio format.
const
KeyTemporalLayeringString. A key describing the temporal layering schema.
const
KeyWidthString. A key describing the width of the content in a video format.
const
MimetypeAudioAacString.
const
MimetypeAudioAc3String.
const
MimetypeAudioAmrNbString.
const
MimetypeAudioAmrWbString.
const
MimetypeAudioFlacString.
const
MimetypeAudioG711AlawString.
const
MimetypeAudioG711MlawString.
const
MimetypeAudioMpegString.
const
MimetypeAudioMsgsmString.
const
MimetypeAudioOpusString.
const
MimetypeAudioQcelpString.
const
MimetypeAudioRawString.
const
MimetypeAudioVorbisString.
const
MimetypeTextCea608String. MIME type for CEA-608 closed caption data.
const
MimetypeTextVttString. MIME type for WebVTT subtitle data.
const
MimetypeVideoAvcString.
const
MimetypeVideoH263String.
const
MimetypeVideoHevcString.
const
MimetypeVideoMpeg2String.
const
MimetypeVideoMpeg4String.
const
MimetypeVideoRawString.
const
MimetypeVideoVp8String.
const
MimetypeVideoVp9String.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

ContainsKey(String) : Boolean
Returns true iff a key of the given name exists in the format.
static
CreateAudioFormat(String, Int32, Int32) : MediaFormat
Creates a minimal audio format.
static
CreateSubtitleFormat(String, String) : MediaFormat
Creates a minimal subtitle format.
static
CreateVideoFormat(String, Int32, Int32) : MediaFormat
Creates a minimal video format.
GetByteBuffer(String) : ByteBuffer
Returns the value of a ByteBuffer key.
GetFeatureEnabled(String) : Boolean
Returns whether a feature is to be enabled (true) or disabled (false).
GetFloat(String) : Single
Returns the value of a float key.
GetInteger(String) : Int32
Returns the value of an integer key.
GetLong(String) : Int64
Returns the value of a long key.
GetString(String) : String
Returns the value of a string key.
SetByteBuffer(String, ByteBuffer)
Sets the value of a ByteBuffer key.
SetFeatureEnabled(String, Boolean)
Sets whether a feature is to be enabled (true) or disabled (false).
SetFloat(String, Single)
Sets the value of a float key.
SetInteger(String, Int32)
Sets the value of an integer key.
SetLong(String, Int64)
Sets the value of a long key.
SetString(String, String)
Sets the value of a string key.