【问题标题】:Configure LAME MP3 encoder in DirectShow application using IAudioEncoderProperties使用 IAudioEncoderProperties 在 DirectShow 应用程序中配置 LAME MP3 编码器
【发布时间】:2010-07-01 15:07:39
【问题描述】:

我正在编写一个 .NET DirectShow 应用程序,它从任何捕获设备捕获音频流,使用 LAME directshow 过滤器将其编码为 mp3,最后将流写入文件。 这是我的直接显示图: 捕获源 -> LAME AUDIO ENCODER(音频压缩器)-> WAV DEST(Wave muxer,从 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 方法似乎对输出文件没有影响。 我尝试使用属性页面配置我的过滤器,它可以工作。

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

问候。

-- 赛弗

【问题讨论】:

    标签: c# .net mp3 directshow lame


    【解决方案1】:

    也许我迟到了,但我遇到了同样的问题。解决方案是在接口中声明方法的顺序与在 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
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-27
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      • 2015-06-02
      相关资源
      最近更新 更多