0

我正在尝试将音频流编码为 IMA ADPCM,这是我的代码。

public Byte[] EncodeDVI(Byte[] source)
        {
            var resampleStream = new AcmStream(new WaveFormat(11025, 16, 1), new ImaAdpcmWaveFormat(11025, 16, 1));
            Buffer.BlockCopy(source, 0, resampleStream.SourceBuffer, 0, source.Length);

            int sourceBytesConverted = 0;
            var convertedBytes = resampleStream.Convert(source.Length, out sourceBytesConverted);
            if (sourceBytesConverted != source.Length)
            {
                Console.WriteLine("We didn't convert everything {0} bytes in, {1} bytes converted");
            }

            var converted = new byte[convertedBytes];
            Buffer.BlockCopy(resampleStream.DestBuffer, 0, converted, 0, convertedBytes);

            return converted;
        }

每次我运行代码时,我都会收到此错误“NAudio.MmException:'AcmNotPossible 调用 acmStreamOpen'”

4

1 回答 1

0

ACM 编解码器只能执行有限数量的转换。您可以使用 NAudio 演示应用程序更详细地探索您的系统上安装了哪些 ACM 编解码器以及它们之间可以转换的内容。

我怀疑在这种情况下,可能是您的采样率不受支持。我在此处编写了有关格式转换的更详细指南,其中解释了您有时需要如何分几个阶段进行转换。

于 2017-09-23T20:17:23.620 回答