Enumerating MPEG2 Format Compatible Compressors Example for C++

The following code demonstrates enumerates the valid audio and video compressors for the MPEG2 target format. A recommended compressor is also retrieved.

// include the LEAD Multimedia TOOLKIT header 
#include "ltmm.h" 
 
void EnumMPEG2Compressors(IltmmConvert *pConvert) 
{ 
   IltmmCompressors *pCompressors; 
   IltmmCompressor *pCompressor; 
   IltmmTargetFormats *pTargetformats; 
   IltmmTargetFormat* pTargetformat; 
   long lCount, lIndex, lValid; 
   BSTR Name; 
 
   // set the target format to MPEG2 
   pConvert->put_TargetFormat(ltmmCapture_TargetFormat_MPEG2_PROGRAM); 
 
   pConvert->get_TargetFormats(&pTargetformats); 
   pTargetformats->Item(ltmmCapture_TargetFormat_MPEG2_PROGRAM, &pTargetformat); 
   pTargetformats->Release(); 
 
   // Audio  
   // get the compressors collection 
   pConvert->get_AudioCompressors(&pCompressors); 
   pCompressors->get_Count(&lCount); 
 
   for (lIndex = 0; lIndex < lCount; lIndex++) 
   { 
      pCompressors->Item(lIndex, &pCompressor); 
      pCompressor->get_Name(&Name); 
      pTargetformat->IsValidCompressor(Name, &lValid); 
      if (lValid != ltmmTargetFormat_Compressor_Invalid) 
      { 
         // do whatever needed with the valid compressor (i.e. add it to some list) 
      } 
      ::SysFreeString(Name); 
      pCompressor->Release(); 
   } 
 
   // get the recommended compressor for the current format 
   pTargetformat->get_RecommendedAudioCompressor(&Name); 
   if (Name) 
   { 
      // do whatever needed with the recommended compressor (i.e. select it) 
   } 
   pCompressors->Release(); 
 
   // Video  
   // get the compressors collection 
   pConvert->get_VideoCompressors(&pCompressors); 
   pCompressors->get_Count(&lCount); 
 
   for (lIndex = 0; lIndex < lCount; lIndex++) 
   { 
      pCompressors->Item(lIndex, &pCompressor); 
      pCompressor->get_Name(&Name); 
      pTargetformat->IsValidCompressor(Name, &lValid); 
      if (lValid != ltmmTargetFormat_Compressor_Invalid) 
      { 
         // do whatever needed with the valid compressor (i.e. add it to some list) 
      } 
      ::SysFreeString(Name); 
      pCompressor->Release(); 
   } 
 
   // get the recommended compressor for the current format 
   pTargetformat->get_RecommendedVideoCompressor(&Name); 
   if (Name) 
   { 
      // do whatever needed with the recommended compressor (i.e. select it) 
   } 
   pCompressors->Release(); 
 
   pTargetformat->Release(); 
} 

Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help