Saving AAC 16kbps



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




file attachments

Closed May 10, 2015 at 10:12 PM by filoe
Can't be fixed. The "problem" gets caused by the media foundation aac encoder.


filoe wrote May 10, 2015 at 10:11 PM

The encoding is done by the media foundation AAC encoder.
Its a great way for encoding audio, but in fact it also gives us some limitations. And yes, you are correct that the aac encoder can only encode with a samplerate of 44.1kHz or 48kHz. For more details, see https://msdn.microsoft.com/en-us/library/windows/desktop/dd742785%28v=vs.85%29.aspx