首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将AAC转换为WAV

将AAC转换为WAV
EN

Stack Overflow用户
提问于 2012-11-21 13:12:15
回答 1查看 5.3K关注 0票数 4

我已经在使用Media Foundation API(感谢MFManagedEncode,http://blogs.msdn.com/b/mf/archive/2010/02/18/mfmanagedencode.aspx)将wav转换为aac。我还没有完全弄清楚它是如何工作的,但它确实起作用了--谢天谢地。

现在我发现很难通过另一种方式进行代码转换,即使有一个MF编解码器(AAC解码器)。我找不到如何使用它的示例,而且我发现它的MSDN文档至少可以说是晦涩难懂的;有人幸运地使用过它吗?

的C#包装器将是理想的。

蒂娅。

EN

回答 1

Stack Overflow用户

发布于 2015-01-13 18:37:55

我已经成功地使用NAudio进行任何音频处理和抽象。它以NuGet的形式提供。它有用于Media Foundation (和其他)的包装器编码器。

下面是一个使用NAudio编码到AAC和返回WAV的示例:

代码语言:javascript
复制
using System;
using NAudio.Wave;

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            // convert source audio to AAC
            // create media foundation reader to read the source (can be any supported format, mp3, wav, ...)
            using (MediaFoundationReader reader = new MediaFoundationReader(@"d:\source.mp3"))
            {
                MediaFoundationEncoder.EncodeToAac(reader, @"D:\test.mp4");
            }

            // convert "back" to WAV
            // create media foundation reader to read the AAC encoded file
            using (MediaFoundationReader reader = new MediaFoundationReader(@"D:\test.mp4"))
            // resample the file to PCM with same sample rate, channels and bits per sample
            using (ResamplerDmoStream resampledReader = new ResamplerDmoStream(reader, 
                new WaveFormat(reader.WaveFormat.SampleRate, reader.WaveFormat.BitsPerSample, reader.WaveFormat.Channels)))
            // create WAVe file
            using (WaveFileWriter waveWriter = new WaveFileWriter(@"d:\test.wav", resampledReader.WaveFormat))
            {
                // copy samples
                resampledReader.CopyTo(waveWriter);
            }
        }
    }
}
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13486747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档