加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 使用IAudioEncoderProperties在DirectShow应用程序中配置L

发布时间:2020-12-15 21:08:16 所属栏目:百科 来源:网络整理
导读:我正在编写.NET DirectShow应用程序,该应用程序从任何捕获设备捕获音频流,使用LAME directshow过滤器将其编码为mp3,最后将流写入文件. 这是我的directshow图: 捕获源 – LAME AUDIO ENCODER(音频压缩器) – WAV DEST(Wave muxer,从SDK sourcres编译) – 文
我正在编写.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
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读