MFCreateAMMediaTypeFromMFMediaType function

Creates a DirectShow AM_MEDIA_TYPE structure from a Media Foundation media type.


HRESULT MFCreateAMMediaTypeFromMFMediaType(
  IMFMediaType  *pMFType,
  GUID          guidFormatBlockType,



Pointer to the IMFMediaType interface of the media type to convert.


Format type GUID. This value corresponds to the formattype member of the AM_MEDIA_TYPE structure and specifies the type of format block to allocate. If the value is GUID_NULL, the function attempts to deduce the correct format block, based on the major type and subtype.


Receives a pointer to an AM_MEDIA_TYPE structure. The caller must release the memory allocated for the structure by calling CoTaskMemFree. The function also allocates memory for the format block, which the caller must release by calling CoTaskMemFree on the pbFormat member.

Return Value

The function returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
The function succeeded.


This function can also be used with the following format structures that are equivalent to AM_MEDIA_TYPE:

  • DMO_MEDIA_TYPE (DirectX Media Objects)
  • WM_MEDIA_TYPE (Windows Media Format SDK)


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header mfapi.h
Library Mfplat.lib
DLL Mfplat.dll

See Also

Media Foundation Functions

Media Type Conversions

Media Types