转换AAC到WAV [英] Convert AAC to WAV

查看:104
本文介绍了转换AAC到WAV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm already using the Media Foundation APIs (thanks to MFManagedEncode, http://blogs.msdn.com/b/mf/archive/2010/02/18/mfmanagedencode.aspx) to convert wav to aac. I haven't fully got my head around how this works, but it does work- thankfully.

现在,即使有MF编解码器(AAC解码器),我也发现很难以其他方式进行转码.我找不到如何使用它的示例,而我正在寻找MSDN文档,至少可以这样说.有人有运气吗?

Now I'm finding it difficult transcoding the other way, even though there is a MF codec for it (AAC Decoder). I can't find examples of how to use this and I'm finding the MSDN documentation for it cryptic to say the least; anyone had an luck with it?

最适合的C#包装器.

TIA.

推荐答案

我已经成功地使用NAudio进行了任何音频处理和抽象.它可以作为NuGet使用.它具有Media Foundation(和其他)的包装编码器.

I have been succesfuly using NAudio for any audio processing and abstraction. It is available as a NuGet. It has wrapper encoders for Media Foundation (and others).

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

Here is a sample for encoding to AAC and back to WAV using NAudio:

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

这篇关于转换AAC到WAV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆