Search code examples
c#audionaudio

Converting MP3 to WAV with low file size


i successfully convert MP3 file to WAV but the problem is my MP3 File size is 53mb and when i convert it to WAV the file size is 250mb, is there a way to make it lower or same file size as possible as mp3?

i don't have problem on my code so i guess i won't post it, but if you want to see i might edit question for code.

i don't have an idea dude...

        using(Mp3FileReader mp3 = new Mp3FileReader(open.FileName))
        {
            using (WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(mp3))
            {
                WaveFileWriter.CreateWaveFile(save.FileName, pcm);
            }
        }

smaller file size is the answer what i want, i choose WAV audio format because it's a requirement for the app i am making.


Solution

  • As MP3 compress the audio, your WAV file will always be larger than your MP3 file. So if you want a lower WAV file size, you need to change your WAV file to a lower bitrate but you will loose quality.

    You have to find the best compromise between your audio quality and the file size.

    The following code is an example changing the bitrate of an MP3 file. You have to adapt it on your case depending the quality you want:

    using (var mp3Reader = new Mp3FileReader(inputFile))
    {
      var wavFormat = new WaveFormat(8000, 16, 1);
      using (var wavStream = new WaveFormatConversionStream(wavFormat, mp3Reader))
      {
        WaveFileWriter.CreateWaveFile(outputFile, wavStream);
      }
    }