Enumerating Audio Codecs

Four properties of FBExportToWMVParams (AudioNumPasses, AudioVBR) require you to select either variable or constant bitrate audio encoding, and to select how many passes will be made in the encoding process.

In order to determine which audio codecs support variable or constant bit rates and multi pass encoding, the IWMCodecInfo3::SetCodecEnumerationSetting method should be used.

The IWMCodecInfo3 interface is defined by the Windows Media Format 9.5 SDK - see http://msdn.microsoft.com for full documentation.

The sample C++ code below uses SetCodecEnumerationSetting to discover which codecs support variable bitrate encoding (VBR), constant bitrate encoding (CBR) and 1 or 2 passes.

 

wchar_t* wszFormatName;

/* Look first for codecs supporting CBR, then VBR */
for (Bool nVbrEnabled = 0; nVbrEnabled < 2; nVbrEnabled++)
{
 hr = pWMCodecInfo3->SetCodecEnumerationSetting(WMMEDIATYPE_Audio, dwCodecId, g_wszVBREnabled,   WMT_TYPE_BOOL, (BYTE*)&nVbrEnabled, sizeof(nVbrEnabled));

  if (hr == S_OK)
 {

   for (DWORD nNumPasses = 1; nNumPasses <= 2; nNumPasses++)
   {
     hr = pWMCodecInfo3->SetCodecEnumerationSetting(WMMEDIATYPE_Audio, dwCodecId, g_wszNumPasses, WMT_TYPE_DWORD, (BYTE*)&nNumPasses, sizeof(nNumPasses));

      if (hr == S_OK)
     {
       DWORD cFormats;
       hr = pWMCodecInfo3->GetCodecFormatCount(WMMEDIATYPE_Audio, dwCodecId, &cFormats);

        if (hr == S_OK)
       {
         for (DWORD i = 0; i < cFormats; i++)
         {
           ...
           pCallbackFunc(i, wszFormatName, (WAVEFORMATEX*)pMediaType->pbFormat, nCurVBR, nCurNumPasses, bSpeechClassEnabled);
           ...
         }
       }
     }
   }
 }
}