Convert AAC to WAV

I already use 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 did not quite understand how this works, but it works - fortunately.

Now it’s hard for me to transcode another way, although there is an MF codec (AAC Decoder) for it. I cannot find examples of how to use this, and I find the MSDN documentation for this cryptic, to say the least; was anyone lucky with him?

C # wrapper for ideal.

TIA.

+4
source share
1 answer

I have successfully used NAudio for any sound processing and abstraction. It is available as NuGet. It has encoders for the Media Foundation (and others).

Here is an example for encoding 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); } } } } 
+4
source

Source: https://habr.com/ru/post/1447400/


All Articles