naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.37k stars 1.09k forks source link

Encode input format must be PCM or IEEE float #1106

Open majiabin opened 5 months ago

majiabin commented 5 months ago

using (WaveFileReader reader = new WaveFileReader(infile)) { MediaFoundationEncoder.EncodeToMp3(reader, mp3FilePath);

}

markheath commented 5 months ago

WAV files sometimes contain compressed audio. Take a look at the WaveFormat of the WaveFileReader, and possibly WaveFormatConversionStream.CreatePcmStream could be used to convert it to PCM (dependent on what codecs are available on your machine)