ImageEn, unit iemmf

TIEMediaFoundationSourceReader.GetMediaType

TIEMediaFoundationSourceReader.GetMediaType


Declaration

function GetMediaType(streamIndex: integer; mediaTypeIndex: integer): TIEDictionary;
function GetMediaType(const streamType: WideString; mediaTypeIndex: integer): TIEDictionary;


Description

Returns the media type for the specified stream and media type index.
Each source stream can support several media types (ie. frame size, frame format, etc..) so GetMediaType provides details about them.

Parameter Description
streamIndex Index of the stream, in the range of 0 to StreamCount - 1
streamType A string representing the stream type. Only the first stream of this type will be considered. Can be any one of the values accepted by GetStreamType
mediaTypeIndex Index of the media type, in the range of 0 to GetMediaTypesCount - 1

The resulting object is a dictionary which contains following media type attributes:
Dictionary key Type Description
IEMAJORTYPE_DICT_KEY string Contains major stream type. See GetStreamType for a list of stream types. The Media Foundation Type is MF_MT_MAJOR_TYPE
IESUBTYPE_DICT_KEY string Contains the media sub type. See below for a list of common values. The Media Foundation Type is MF_MT_SUBTYPE
IECOMPRESSED_DICT_KEY boolean If this attribute is True, the media type is a compressed format. The Media Foundation Type is MF_MT_COMPRESSED
IEAVGBITRATE_DICT_KEY integer Approximate data rate of the video stream, in bits per second. The Media Foundation Type is MF_MT_AVG_BITRATE
IEDEFAULTSTRIDE_DICT_KEY integer The number of bytes needed to go from one row of pixels to the next. The Media Foundation Type is MF_MT_DEFAULT_STRIDE
IEFRAMERATE_DICT_KEY double Frame rate of a video media type, in frames per second. The Media Foundation Type is MF_MT_FRAME_RATE
IEFRAMERATEMAX_DICT_KEY double The maximum frame rate that is supported by a video capture device, in frames per second. The Media Foundation Type is MF_MT_FRAME_RATE_RANGE_MAX
IEFRAMERATEMIN_DICT_KEY double The minimum frame rate that is supported by a video capture device, in frames per second. The Media Foundation Type is MF_MT_FRAME_RATE_RANGE_MIN
IEFRAMEWIDTH_DICT_KEY integer Width of a video frame, in pixels. The Media Foundation Type is MF_MT_FRAME_SIZE (high dword)
IEFRAMEHEIGHT_DICT_KEY integer Height of a video frame, in pixels. The Media Foundation Type is MF_MT_FRAME_SIZE (low dword)
IEINTERLACEMODE_DICT_KEY string Describes how the frames in a video media type are interlaced. The Media Foundation Type is MF_MT_INTERLACE_MODE
IEVIDEOLIGHTING_DICT_KEY string Specifies the optimal lighting conditions for a video media type. Allowed values are: 'Bright', 'Office', 'Dim' and 'Dark'. The Media Foundation Type is MF_MT_VIDEO_LIGHTING
IEAUDIOBITSPERSAMPLE_DICT_KEY integer Number of bits per audio sample in an audio media type. The Media Foundation Type is MF_MT_AUDIO_BITS_PER_SAMPLE
IEAUDIOFLOATSAMPLESPERSECOND_DICT_KEY double Number of audio samples per second. The Media Foundation Type is MF_MT_AUDIO_FLOAT_SAMPLES_PER_SECOND
IEAUDIONUMCHANNELS_DICT_KEY integer Number of audio channels. The Media Foundation Type is MF_MT_AUDIO_NUM_CHANNELS
IEAUDIOSAMPLESPERSECOND_DICT_KEY integer Number of audio samples per second. The Media Foundation Type is MF_MT_AUDIO_SAMPLES_PER_SECOND
IEAUDIOBLOCKALIGNMENT_DICT_KEY integer Block alignment, in bytes. For PCM audio formats, the block alignment is equal to the number of audio channels multiplied by the number of bytes per audio sample. The Media Foundation Type is MF_MT_AUDIO_BLOCK_ALIGNMENT
IEALLSAMPLESINDEPENDENT_DICT_KEY boolean Specifies for a media type whether each sample is independent of the other samples. The Media Foundation Type is MF_MT_ALL_SAMPLES_INDEPENDENT
IEAUDIOAVGBYTESPERSECOND_DICT_KEY integer Average number of bytes per second. The Media Foundation Type is MF_MT_AUDIO_AVG_BYTES_PER_SECOND

The Video media sub types (IESUBTYPE_DICT_KEY) are: 'RGB8', 'RGB555', 'RGB565', 'RGB24', 'RGB32', 'ARGB32', 'AI44', 'AYUV', 'YUY2', 'YVYU', 'YVU9', 'UYVY', 'NV11', 'NV12', 'YV12', 'I420', 'IYUV', 'Y210', 'Y216',
'Y410', 'Y416', 'Y41P', 'Y41T', 'Y42T', 'P210', 'P216', 'P010', 'P016', 'v210', 'v216', 'v410', 'MP43', 'MP4S', 'M4S2', 'MP4V', 'WMV1', 'WMV2', 'WMV3', 'WVC1', 'MSS1', 'MSS2',
'MPG1', 'dvsl', 'dvsd', 'dvhd', 'dv25', 'dv50', 'dvh1', 'dvc ', 'H264', 'MJPG'.

The Audio media sub types (IESUBTYPE_DICT_KEY) are: 'PCM', 'Float', 'DTS', 'Dolby_AC3_SPDIF', 'DRM', 'WMAudioV8', 'WMAudioV9', 'WMAudio_Lossless', 'WMASPDIF', 'MSP1', 'MP3', 'MPEG', 'AAC', 'ADTS'.

The interlace modes (IEINTERLACEMODE_DICT_KEY) are: 'Progressive', 'FieldInterleavedUpperFirst', 'FieldInterleavedLowerFirst', 'FieldSingleUpper', 'FieldSingleLower', 'MixedInterlaceOrProgressive'.


Example

// Fill supported formats listbox
ListBox1.Clear();
with ImageEnView1.IO.MediaFoundationSourceReader do
begin
  SetVideoInput(ComboBox1.ItemIndex);
  for i := 0 to GetMediaTypesCount(mmf_VIDEO_STREAM) - 1 do
  begin
    mediaType := GetMediaType(mmf_VIDEO_STREAM, i);
    ListBox1.Items.Add(Format('%d x %d   %.1f fps (min fps: %.1f max fps: %.1f)   %s',
          [mediaType.GetInteger(IEFRAMEWIDTH_DICT_KEY),    // width
           mediaType.GetInteger(IEFRAMEHEIGHT_DICT_KEY),   // height
           mediaType.GetDouble(IEFRAMERATE_DICT_KEY),      // default frame rate
           mediaType.GetDouble(IEFRAMERATEMIN_DICT_KEY),   // minimum frame rate
           mediaType.GetDouble(IEFRAMERATEMAX_DICT_KEY),   // maximum frame rate
           mediaType.GetString(IESUBTYPE_DICT_KEY)         // subtype = color space
           ]));
  end;
end;


See Also

StreamCount
GetMediaTypesCount