Saving AAC 16kbps

May 8, 2015 at 12:41 PM
Hi

I am currently trying to create a recording application, but cannot save the output in AAC encoding with specified values such as a 16Kbps bitrate and 16Khz sampling rate.

In a previous version of my application I am able to change sample and bit rates,saving it in mp3 encoding, while using VLC.

This version I want to upgrade to AAC encoding and to remove reliance on VLC.

Am I correct in assuming that Media Foundation cannot save to custom sample rates other than 44.1khz and 48khz?

The following code creates AAC file, but I cant change sample rates.
using (var wasapiCapture = new WasapiCapture())
            {
                wasapiCapture.Initialize();
                var wasapiCaptureSource = new SoundInSource(wasapiCapture);
                using (var stereoSource = wasapiCaptureSource.ToStereo())
                { 
                    using (AacEncoder writer = (AacEncoder)MediaFoundationEncoder.CreateAACEncoder(stereoSource.WaveFormat, fileName))
                    {
                        byte[] buffer = new byte[stereoSource.WaveFormat.BytesPerSecond];
                        wasapiCaptureSource.DataAvailable += (s, e) =>
                        {
                            int read = stereoSource.Read(buffer, 0, buffer.Length);
                            writer.Write(buffer, 0, read);
                        };

                        wasapiCapture.Start();

                        Console.ReadKey();

                        wasapiCapture.Stop();
                    }
                }
            }
Coordinator
May 10, 2015 at 10:15 PM
Please stick to the issue you've reported: https://cscore.codeplex.com/workitem/26