3

Given an aac audio byte array, convert to an mp3 audio in bytes. This is what I tried, but I this an exception

"Got a frame at sample rate 24000, in an MP3 with sample rate 16000. Mp3FileReader does not support sample rate changes"

  public static byte[] AacToMp3(byte[] aacAudioBytes)
    {
        using (var aacStream = new MemoryStream(aacAudioBytes))
        using (var mp3stream = new MemoryStream())
        using (var reader = new Mp3FileReader(aacStream))// or I tried AudioFileReader/MediaFoundationReader
        using (var mp3Writer = new LameMP3FileWriter(mp3stream, reader.WaveFormat, LAMEPreset.ABR_32))
        {
            reader.CopyTo(mp3Writer);
            return mp3stream.GetBuffer();
        }
    }

What am I missing?

1
  • 1
    Same problem here. I'll post an answer when I find one.
    – Ch3shire
    Nov 22, 2017 at 22:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.