Encoding Properties

The Windows Media Audio and Windows Media Video encoders support a variety of encoding modes. These modes are generally configured by setting properties on the encoder Media Foundation transform (MFT). To perform file encoding, whether using WMContainer-level components or by building a partial topology, you must configure the encoder appropriately by setting properties depending on the mode of encoding and the media type of the stream. The same set of properties must be set both on the encoder and the object (ASF file sink or ASF multiplexer) you are using to write the ASF file.

The encoder properties are defined in wmcodecdsp.h. The specific properties that are used to configure the encoder are set by using the methods of the IPropertyStore interface.

Audio Stream Properties

The following table shows the encoder configurations for an audio stream.

Encoding type Property name - Value
Constant Bit Rate Encoding MFPKEY_VBRENABLED - FALSE (Optional)By default, MFPKEY_VBRENABLED is set to FALSE.
Quality-Based Variable Bit Rate Encoding MFPKEY_VBRENABLED - TRUE
MFPKEY_PASSESUSED - 1 (Optional)
By default, MFPKEY_PASSESUSED is set to 1.
MFPKEY_DESIRED_VBRQUALITY - From 0 to 100
Unconstrained Variable Bit Rate Encoding MFPKEY_VBRENABLED - TRUE
MFPKEY_PASSESUSED - 2
Peak-Constrained Variable Bit Rate Encoding MFPKEY_VBRENABLED - TRUE
MFPKEY_PASSESUSED - 2
MFPKEY_RMAX - Maximum bit rate
MFPKEY_BMAX - Maximum buffer window

 

Video Stream Properties

The following table shows the encoder configurations for a video stream.

Encoding type Property name
Constant Bit Rate Encoding MFPKEY_VBRENABLED - FALSE (Optional)
By default, MFPKEY_VBRENABLED is set to FALSE.
MFPKEY_VIDEOWINDOW - Buffer window
Quality-Based Variable Bit Rate Encoding MFPKEY_VBRENABLED - TRUE
MFPKEY_PASSESUSED - 1 (Optional)
By default, MFPKEY_PASSESUSED is set to 1.
MFPKEY_DESIRED_VBRQUALITY - From 0 to 100
Unconstrained Variable Bit Rate Encoding MFPKEY_VBRENABLED - TRUE
MFPKEY_PASSESUSED - 2
Peak-Constrained Variable Bit Rate Encoding MFPKEY_VBRENABLED - TRUE
MFPKEY_PASSESUSED - 2
MFPKEY_RMAX - Maximum bit rate
MFPKEY_BMAX - Maximum buffer window

 

Configuring the Encoder's Property Store

You must configure an encoder by specifying the type of encoding and the various stream-specific settings before the encoding session. You must also set the encoder properties in the property store of an ASF ContentInfo Object that represents the ASF Header Object of the output file.

If you are using an encoder MFT:

  1. Get a reference to the encoder MFT's IMFTransform interface as described in Using an Encoder's IMFTransform Interface.
  2. Querying the encoder MFT for the IPropertyStore interface.
  3. Setting the required properties by calling IPropertyStore::SetValue.

If you are using the built-in encoder activation objects and have already created an configured the ASF file sink, you can pass the ASF media sink's property store to MFCreateWMAEncoderActivate or MFCreateWMVEncoderActivate. The encoder is configured automatically based on the settings specified by the application. For more information, see the procedure described in Using an Encoder's Activation Objects.

For more information about creating Media Foundation objects by using activation objects, see Activation Objects.

Instantiating an Encoder MFT

Windows Media Encoders