微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 使用IAudioEncoderProperties在DirectShow应用程序中配置LAME MP3编码器

我正在编写.NET DirectShow应用程序,该应用程序从任何捕获设备捕获音频流,使用LAME directshow过滤器将其编码为mp3,最后将流写入文件.
这是我的directshow图:
捕获源 – > LAME AUdio ENCODER(音频压缩器) – > WAV DEST(Wave muxer,从SDK sourcres编译) – >文件编写者.

问题是我想以编程方式配置编码器(比特率,通道,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方法似乎没有输出文件.
我尝试使用属性页面配置我的过滤器,它的工作原理.

所以,我想知道是否有人已经将LAME编码器用于DirectShow应用程序(无论是否为.NET)并且可以给我一些帮助?

问候.


Sypher

解决方法

也许我迟到了,但我遇到了同样的问题.解决方案是在接口中声明方法的顺序与在LAME源中声明的顺序完全相同.

[ComImport]
[SuppressUnmanagedCodeSecurity]
[InterfaceType(ComInterfaceType.InterfaceIsIUnkNown)]
[Guid("ca7e9ef0-1cbe-11d3-8d29-00a0c94bbfee")]
public interface IAudioEncoderProperties
{
    /// <summary>
    /// Is PES output enabled? Return TRUE or FALSE
    /// </summary>      
    int get_PESOutputEnabled([Out] out int dwEnabled);

    /// <summary>
    /// Enable/disable PES output
    /// </summary>      
    int set_PESOutputEnabled([In] int dwEnabled);

    /// <summary>
    /// Get target compression bitrate in Kbits/s
    /// </summary>      
    int get_Bitrate([Out] out int dwBitrate);

    /// <summary>
    /// Set target compression bitrate in Kbits/s
    /// Not all numbers available! See spec for details!
    /// </summary>      
    int set_Bitrate([In] int dwBitrate);

    ///... the rest of interface
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐