views:

13

answers:

0

Hi,

I'm writting a .NET DirectShow application which captures audio stream from any capture device, encodes it in mp3 using the LAME directshow filter and finally writes the stream into a file. This is my directshow graph: capture source -> LAME AUDIO ENCODER (Audio compressor) -> WAV DEST (Wave muxer, compiled from SDK sourcres) -> File writer.

The problem is that I'd like to configure the encoder (bitrate, channels, VBR/CBR, etc) programmatically and not using the properties pages (ISpecifyPropertyPages) available on the LAME encoder.

After retrieving LAME sources, it appears that the configuration must be done using the specific IAudioEncoderProperties interface.

I tried to marshal this COM interface in my .NET application using this declaration:

 
 [ComImport]
 [SuppressUnmanagedCodeSecurity]
 [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
 [Guid("ca7e9ef0-1cbe-11d3-8d29-00a0c94bbfee")]
 public interface IAudioEncoderProperties
 {
   // Get target compression bitrate in Kbits/s
   int get_Bitrate(out int dwBitrate);

   // Set target compression bitrate in Kbits/s
   // Not all numbers available! See spec for details!
   int set_Bitrate(int dwBitrate);
 }

Note that not all methods are redefined.

I can successfully cast my audio compressor filter (the LAME encoder) using:

IAudioEncoderProperties prop = mp3Filter as AudioEncoderProperties;

But when I call get_Bitrate method the returned value is 0 and calling the set_Bitrate method seems to have no incidence on the output file. I tried configuring my filter using the properties pages and it works.

So, I'd like to know if anybody has already used the LAME encoder into a DirectShow application (.NET or not) and could bring me some help?

Regards.

-- Sypher