srieen
srieen

Reputation: 59

Improve NAudio Mp3 Audio Quality

I’m using NAudio and Lame Audio to Convert Wav to Mp3, I’m newbie too for this Audio Conversion code. Thanks to Mark I’m using his Audio File Inspector to get the details

Here is the details

Input - Wave Format details

Opening D:\Data\Test\NAudio\Wav\[email protected]

DviAdpcm 8000Hz 2 channels 4 bits per sample

Extra Size: 2 Block Align: 512 Average Bytes Per Second: 8110

WaveFormat: DviAdpcm Length: 788808 bytes: 00:01:37.2640000

Chunk: fact, length 420 D9 0B 00


Output Mp3

Opening D:\Data\Test\NAudio\Mp3\[email protected]

MP3 File WaveFormat: MpegLayer3 8000Hz 2 channels 0 bits per sample

Extra Size: 12 Block Align: 1 Average Bytes Per Second: 3000

ID: Mpeg Flags: PaddingIso Block Size: 216 Frames per Block: 1

Length: 3119616 bytes: 00:01:37.4880000

ID3v1 Tag: None

ID3v2 Tag: None

Version25,Layer3,8000Hz,JointStereo,24000bps, length 216 Version25,Layer3,8000Hz,JointStereo,24000bps, length 216

….

….

I’m Converting Wav to Mp3 ( voice recording files).

Question : I’m seeing some compromise in Mp3 Quality, My converted Mp3 is lower file size when compared to Wav, but my audio quality is little poor than Wav, Wonder if i can increase the quality of the Mp3 file ? Something like increasing the Bitrate etc.

Code for Wav to Mp3 conversation using NAudio / Lame Audio

string filePath = @"D:\Data\Test\NAudio\Wav\11mb.wav";
string outputPath = @"D:\Data\Test\NAudio\Mp3\11mb.mp3";

using (WaveFileReader wavReader = new WaveFileReader(filePath))
using (WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(wavReader))
using (LameMP3FileWriter fileWriter = new LameMP3FileWriter(outputPath, pcm.WaveFormat, LAMEPreset.VBR_90))
{
    pcm.CopyTo(fileWriter);
}

Upvotes: 0

Views: 1873

Answers (2)

Andrew Haas
Andrew Haas

Reputation: 51

MP3 is a heavily compressed codec, it will never get close to the original .Wav quality.

However, if you look at the original .Wav quality, you are starting from a very poor recording. When the Hz and bit depth are that low, there is all sorts of artifacts getting created as the wavform is very poorly represented digitally to start with.

anything under CD quality is going to have a LOT of problems being compressed because so much is missing to begin with.

Perfect for making "Boards of Canada" music though. :)

Upvotes: 0

srieen
srieen

Reputation: 59

This link has more details on my above question

http://mark-dot-net.blogspot.com/search/label/NAudio

Upvotes: 1

Related Questions