Enumerating MPEG2 Format Compatible Compressors Example for Visual Basic

' the following code demonstrates enumerates the valid audio and video compressors for the
' MPEG2 target format The format to be used for the converted file. This includes the file format, any special settings used by that format, and which audio and/or video codec A COmpressor combined with a DECompressor, or encoder and a decoder, which allows you to both compress and decompress that same data. is to be used for the conversion, and any special settings used by the codecs.. A recommended compressor Also known as an encoder Also known as compressor, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder., this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder Also known as a decompressor, this is a module or algorithm to decompress data.. is also retrieved.

Private Sub EnumMPEG2Compressors(Convert As ltmmConvertCtrl)
   Dim TargetFormat As IltmmTargetFormat
   Dim lIndex As Long

   ' set the target format to MPEG2
   Convert.TargetFormat = ltmmCapture_TargetFormat_MPEG2_PROGRAM
   Set TargetFormat = Convert.TargetFormats.Item(ltmmCapture_TargetFormat_MPEG2_PROGRAM)
   
   ' Audio
   For lIndex = 0 To (ltmmConvert.AudioCompressors.Count - 1)
        If TargetFormat.IsValidCompressor(ltmmConvert.AudioCompressors.Item(lIndex).Name) <> ltmmTargetFormat_Compressor_Invalid Then
           ' do whatever needed with the valid compressor (i.e. add it to some list)
        End If
   Next

   ' get the recommended compressor for the current format
   lIndex = Convert.AudioCompressors.Find(TargetFormat.RecommendedAudioCompressor)
   ' do whatever needed with the recommended compressor (i.e. select it)
   Convert.AudioCompressors.selection = lIndex

   ' Video
   For lIndex = 0 To (ltmmConvert.VideoCompressors.Count - 1)
        If TargetFormat.IsValidCompressor(ltmmConvert.VideoCompressors.Item(lIndex).Name) <> ltmmTargetFormat_Compressor_Invalid Then
           ' do whatever needed with the valid compressor (i.e. add it to some list)
        End If
   Next

   ' get the recommended compressor for the current format
   lIndex = Convert.VideoCompressors.Find(TargetFormat.RecommendedVideoCompressor)
   ' do whatever needed with the recommended compressor (i.e. select it)
   Convert.VideoCompressors.selection = lIndex

End Sub