To Transcode Content with Smart Recompression

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

You can transcode content from one bit rate to another using the Windows Media Format SDK. Normally, this involves simply decoding the content and encoding it again to the desired bit rate. The Windows Media Audio 9 codec supports smart recompression, which enables transcoding that achieves better quality than normal.

For smart recompression, the original audio stream must be encoded with the Windows Media Audio codec. All versions of the codec are supported, but the specialized audio codecs (Windows Media Audio 9 Professional and Windows Media Audio 9 Voice) are not. If the original audio was encoded with the Windows Media Audio 9 Lossless codec, there is no need to use smart recompression, because no information was lost in the original encoding.

To use smart recompression, perform the following steps.

  1. Set up a reader object with the source file for reading. For more information, see Reading ASF Files.
  2. Set up a writer object to use for transcoding the file. Set the file name for the new file. Select a profile to use for the new file. Set the selected profile in the writer object. For more information, see Writing ASF Files.
  3. Get a pointer to the IWMProfile interface of the reader object by calling IWMReader::QueryInterface.
  4. Retrieve the IWMStreamConfig interface for the audio stream to be transcoded by calling IWMProfile::GetStream.
  5. Get the IWMMediaProps interface for the stream configuration object by calling IWMStreamConfig::QueryInterface.
  6. Retrieve the WM_MEDIA_TYPE structure for the stream by making two calls to IWMMediaProps::GetMediaType. Get the size of the structure on the first call, and allocate memory for a buffer to pass on the second call.
  7. Get a pointer to the IWMInputMediaProps interface for the input in the writer by calling IWMWriter::GetInputProps.
  8. Get the IWMPropertyVault interface for the input media properties object by calling IWMInputMediaProps::QueryInterface.
  9. Use the IWMPropertyVault::SetProperty method to set the g_wszOriginalWaveFormat property. Use the WAVEFORMATEX structure obtained in step 6 as the value of the property.
  10. Include changes made to the input media properties by calling IWMWriter::SetInputProps and passing it a pointer to the IWMInputMediaProps interface.
  11. Begin reading samples from the original file and passing them to the writer with calls to IWMWriter::WriteSample.

Advanced Topics

IWMInputMediaProps Interface

IWMMediaProps Interface

IWMProfile Interface

IWMPropertyVault Interface

IWMStreamConfig Interface