MFSimpleEncode.exe - This is a command line tool that transcodes files from one media format to another. The source code is provided to use as a reference if you write your own transcode application. This tool uses the Media Foundation transcode API, which was introduced in Windows 7.


Transcoding is converting from one media format to another. Media Foundation provides three ways to perform transcoding:


Figure 1. Three ways to perform transcoding

Configuring the media session directly is not straightforward. For example, you must understand the different encoders and media sinks to configure them properly. The transcode API provides a set of functions that makes it easier to build a transcode pipeline. It provides a simple profile to configure different encoders and sinks in the same way, and it automatically transfers metadata from the source file to the transcoded file.

Here is how to use the transcode API:

The transcode API is based on the media session, so you don’t need to manipulate the samples yourself, or understand the low-level details. However, if you need to manipulate the sample data – for example, to add effects to the samples before encoding them -- the source reader and sink writer might be a better choice. We will have some topics about the source reader and sink writer later in this series.

To read more about the transcode API:

Project Structure:


The main project file for VC++ projects generated using an Application Wizard. It contains information about the version of Visual C++ that generated the file, and information about the platforms, configurations, and project features selected with the Application Wizard.


The main application source file.


This is the encoding engine that the application calls into.


This class handles asynchronous callbacks.


This class is used to create the preferred output media types for transcoding.


This class is used to create a Media Foundation media source from a URL.


MFSimpleEncode.exe -i INPUTFILE -o OUTPUTFILE [-p PROFILE] [-t DURATION] [-splitAudio CONTAINER] [-splitVideo CONTAINER] [-remux CONTAINER]


The path to the input file. The tool supports built-in input file formats: ASF, AVI, WAV, MPEG4, 3GP, MP3 and the registered 3rd party MF sources.


The path to the output file. It is highly recommended that you include the correct file extension, based on the file container. The tool supports built-in output file formats: ASF, MPEG4, 3GP and MP3.


The path to the transcode profile file. Some example profiles are provided under .\profiles. They are in XML format, so that you can easily see the configuration or modify them for your own use. Several example profiles are included:

    • TranscodeProfileASF.xml - Transcodes to an ASF file.
    • TranscodeProfileMPEG4.xml - Transcodes to an MPEG-4 file.
    • TranscodeProfileWMA_64k.xml - Transcode to a 64kbps WMA file.
    • TranscodeProfileWMA_128k.xml - Transcode to a 128kbps WMA file.
    • TranscodeProfileWMA_160k.xml - Transcode to a 160kbps WMA file.
    • TranscodeProfileWMA_196k.xml - Transcode to a 196kbps WMA file.


Specifies a stop time earlier than the end of file, in milliseconds. Use this parameter to get a segment of the original file.

- splitAudio CONTAINER

Splits the audio stream from the original file, without re-encoding.

- splitVideo CONTAINER

Splits the video stream from the original file, without re-encoding.


Remux the streams from the original file, without re-encoding.

CONTAINER specifies the file container type. Currently, the tool supports the following container name strings:

    • “MPEG4”
    • “ASF”
    • “3GP”
    • “MP3”

It is highly recommended keeping the same container type as the input file container for remuxing and splitting scenarios. For example, if the input file format is ASF/WMV/WMA, “ASF” will be the preferred CONTAINER name string.

The following options are mutually exclusive: -p, -splitAudio, -splitVideo, -remux.


1. Transcode ASF to MPEG-4:

MFSimpleencode.exe –i Input.wmv –o output.mp4 –p TranscodeProfileMPEG4.xml

2. Transcode MPEG-4 to ASF:

MFSimpleencode.exe –i input.mp4 –o output.wmv –p TranscodeProfileASF.xml

3. Strip audio from ASF:

MFSimpleencode.exe –i input.wmv –o output.wma -splitAudio ASF

4. Strip video from MPEG-4:

MFSimpleencode.exe –i input.mp4 –o output.mp4 –splitVideo MPEG4

5. Get a 2-second segment from a WMA file:

MFSimpleencode.exe -i input.wma –o output.wma –remux ASF –t 2000


  1. The Media Foundation transcode API supports a maximum of one audio stream and one video stream in the output file.
  2. This tool does not support DRM transcoding.
  3. This tool cannot transcode to mp3 file format unless a 3rd party mp3 encoder MFT is installed. This is because the inbox mp3 encoder MFT is licensed for Microsoft applications only and will not work when loaded by 3rd party applications.
  4. Remuxing/splitting to different containers might fail due to the specific container requirements.

Downloading the Sample

You can download MFSimpleEncode from

Follow the instruction at for tips and instructions to build the sample.

This posting is provided "AS IS" with no warranties and confers no rights.

Comments (2)
  1. Ran as follows:

    MFSimpleencode.exe –i Input.wmv –o output.mp4 –p TranscodeProfileMPEG4.xml

    MP4 file has audio and video sync issues. How do I fix that?

  2. _mms says:

    Hello there,

    Wondering if you have any suggestions on how to store a custom timestamp along with each encoded sample (H.264 using sinkwriter). When trying to set MFSampleExtension_DeviceTimestamp or MFSampleExtension_DeviceReferenceSystemTime no matter what the values do not show up when decoding the frame. Also the file size does not change at all suggesting that sinkwriter or the encoder does not actually write these into the stream.

    All I need is to store a 64bit value along with each sample or frame, any suggestions?

    Thanks in advance!

Comments are closed.

Skip to main content