IMFSinkWriter::SetInputMediaType method (mfreadwrite.h)

Sets the input format for a stream on the sink writer.


HRESULT SetInputMediaType(
  [in] DWORD         dwStreamIndex,
  [in] IMFMediaType  *pInputMediaType,
  [in] IMFAttributes *pEncodingParameters


[in] dwStreamIndex

The zero-based index of the stream. The index is received by the pdwStreamIndex parameter of the IMFSinkWriter::AddStream method.

[in] pInputMediaType

A pointer to the IMFMediaType interface of a media type. The media type specifies the input format.

[in] pEncodingParameters

A pointer to the IMFAttributes interface of an attribute store. Use the attribute store to configure the encoder. This parameter can be NULL.

Return value

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

Return code Description
The method succeeded.
The underlying media sink does not support the format, no conversion is possible, or a dynamic format change is not possible.
The dwStreamIndex parameter is invalid.
Could not find an encoder for the encoded format.


The input format does not have to match the target format that is written to the media sink. If the formats do not match, the method attempts to load an encoder that can encode from the input format to the target format.

After streaming begins—that is, after the first call to IMFSinkWriter::WriteSample—you can call this method at any time to change the input format. However, the underlying encoder and media sink must support dynamic format changes.

This interface is available on Windows Vista if Platform Update Supplement for Windows Vista is installed.


Requirement Value
Minimum supported client Windows 7, Windows Vista and Platform Update Supplement for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header mfreadwrite.h

See also


Sink Writer