MFInitVideoFormat function (mfapi.h)

[This API is not supported and may be altered or unavailable in the future. Applications should avoid using the MFVIDEOFORMAT structure, and use media type attributes instead. For more information, see Video Media Types.]

Initializes an MFVIDEOFORMAT structure for a standard video format such as DVD, analog television, or ATSC digital television.


HRESULT MFInitVideoFormat(
  [out] MFVIDEOFORMAT         *pVideoFormat,
  [in]  MFStandardVideoFormat type


[out] pVideoFormat

A pointer to an MFVIDEOFORMAT structure. The function fills in the structure members based on the video format specified in the type parameter.

[in] type

The video format, specified as a member of the MFStandardVideoFormat enumeration.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


Note  Prior to Windows 7, this function was exported from evr.dll. Starting in Windows 7, this function is exported from mfplat.dll, and evr.dll exports a stub function that calls into mfplat.dll. For more information, see Library Changes in Windows 7.


The following example creates a media type object for a standard video format.

// Creates a media type for a standard video format.
HRESULT CreateStandardVideoMediaType(MFStandardVideoFormat type, IMFMediaType **ppMediaType)
    IMFMediaType *pMediaType = NULL;


    // Fill in the MFVIDEOFORMAT structure for the video format.
    HRESULT hr = MFInitVideoFormat(&format, type);
    if (FAILED(hr))
        goto done;

    // Create a new (empty) media type.
    hr = MFCreateMediaType(&pMediaType);
    if (FAILED(hr))
        goto done;

    // Initialize the media type from the MFVIDEOFORMAT structure.
    hr = MFInitMediaTypeFromMFVideoFormat(pMediaType, &format, sizeof(format));
    if (FAILED(hr))
        goto done;

    // Return the pointer to the caller.
    *ppMediaType = pMediaType;

    return hr;


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

See also

Media Foundation Functions

Media Types

Video Media Types