MFCreateTranscodeTopology function

Creates a partial transcode topology.

The underlying topology builder creates a partial topology by connecting the required pipeline objects: source, encoder, and sink. The encoder and the sink are configured according to the settings specified by the caller in the transcode profile.

To create the transcode profile object, call the MFCreateTranscodeProfile function and set the required attributes by calling the appropriate the IMFTranscodeProfile methods.

The configured transcode profile is passed to the MFCreateTranscodeTopology function, which creates the transcode topology with the appropriate settings. The caller can then set this topology on the Media Session and start the session to begin the encoding process. When the Media Session ends, the transcoded file is generated.


STDAPI MFCreateTranscodeTopology(
  _In_  IMFMediaSource      *pSrc,
  _In_  LPCWSTR             pwszOutputFilePath,
  _In_  IMFTranscodeProfile *pProfile,
  _Out_ IMFTopology         **ppTranscodeTopo


pSrc [in]

A pointer to a media source that encapsulates the source file to be transcoded. The media source object exposes the IMFMediaSource interface and can be created by using the source resolver. For more information, see Using the Source Resolver.

pwszOutputFilePath [in]

A pointer to a null-terminated string that contains the name and path of the output file to be generated.

pProfile [in]

A pointer to the transcode profile that contains the configuration settings for the audio stream, the video stream, and the container to which the file is written. The transcode profile object exposes the IMFTranscodeProfile interface and must be created by calling the MFCreateTranscodeProfile function. After the object has been created the caller must provide the configuration settings by calling appropriate the IMFTranscodeProfile methods.

ppTranscodeTopo [out]

Receives a pointer to the IMFTopology interface of the transcode topology object. The caller must release the interface.

Return value

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

Return codeDescription

The function call succeeded, and ppTranscodeTopo receives a pointer to the transcode topology.


pwszOutputFilePath contains invalid characters.


No streams are selected in the media source.


The profile does not contain the MF_TRANSCODE_CONTAINERTYPE attribute.


For one or more streams, cannot find an encoder that accepts the media type given in the profile.


The profile does not specify a media type for any of the selected streams on the media source.



For example code that uses this function, see the following topics:


Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]







See also

Media Foundation Functions
Transcode API