使用 IAudioEncoderProperties 在 DirectShow 应用程序中配置 LAME MP3 编码器
我正在编写一个 .NET DirectShow 应用程序,它从任何捕获设备捕获音频流,使用 LAME directshow 过滤器将其编码为 mp3,最后将流写入文件。 这是我的直接显示图: 捕获源-> LAME AUDIO ENCODER(音频压缩器)-> WAV DEST(Wave 复用器,从 SDK 源代码编译)->文件编写器。
问题是我想以编程方式配置编码器(比特率、通道、VBR/CBR 等),而不是使用 LAME 编码器上可用的属性页 (ISpecifyPropertyPages)。
检索 LAME 源后,似乎必须使用特定的 IAudioEncoderProperties 接口来完成配置。
我尝试使用以下声明在我的 .NET 应用程序中封送此 COM 接口:
[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);
}
请注意,并非所有方法都被重新定义。
我可以使用以下方法成功地转换我的音频压缩器过滤器(LAME 编码器):
IAudioEncoderProperties prop = mp3Filter as AudioEncoderProperties;
但是当我调用 get_Bitrate 方法时,返回值为 0 并且调用 set_Bitrate 方法似乎对输出文件没有影响。 我尝试使用属性页面配置我的过滤器并且它有效。
所以,我想知道是否有人已经在 DirectShow 应用程序(.NET 或非 .NET)中使用了 LAME 编码器并且可以给我带来一些帮助?
问候。
-- 西弗
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许我迟到了,但我遇到了同样的问题。解决方案是按照与 LAME 源中声明的顺序完全相同的顺序在接口中声明方法。
Maybe I am late, but I ran in the same problem. The solution is to declare methods in your interface in exactly same order as they are declared in LAME sources.