将AAC转换为WAV

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

现在我发现很难以其他方式进行转码,即使它有一个MF编解码器(AAC解码器)。 我找不到如何使用这个的例子,我发现它的MSDN文档至少可以说是含糊不清的; 谁有运气呢?

AC#wrapper for是理想的。

TIA。

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

以下是使用NAudio编码为AAC并返回WAV的示例:

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); } } } }