0

I am working with some large mp3 sound files. Ranging from a few hours to 15+ hours. I need to convert these mp3 files into wav. Due to the size of the files it is not possible to load a whole file and then convert it.

My solution so far is using NAudio and NAudio.Lame I have modified: Mp3FileReader and Mp3FrameDecompressor to my needs. And this works, I can load in 100 mb chucks at a time and convert it. Due to my implementation I can load a Mp3 fils where each frame in the same mp3 file varies slightly (1 frame is mono and another is stereo in the same file).

This is all good.

My problem is the timing between the original mp3 and the generated wav. An example is a 9 hours 34 minutes and 38 seconds mp3 file, generated to a wav file is only 9 hours 21 minutes and 15 seconds long.

That is a lose of 13 minutes and 23 seconds, 3.7% shorter!. But I can not find anything which is lost in the audio. Everything seems to be there, it is just, shorter. Like the audio is played 3.7% faster than the mp3. It is a problem for me, because I need to be able to make a mapping between the wav and mp3 at a later date, and I would greatly prefer the mapping is 1 to 1.

I have tried to import the Mp3 file into Audacity with the same result, the imported audio in Audacity is again 13 minutes shorter than the original mp3 file.

This leads me to think the problem is not my code alone, is there an explanation to this behavior?

Jason Evans
  • 28,906
  • 14
  • 90
  • 154
Mr. JWolf
  • 1,375
  • 2
  • 14
  • 33
  • i don't think you are loosing audio data but after the conversion the new audio is running slightly faster than the original and that's why it's getting shorter. make sure the sampling rate of the converted data match the source – Sam Aug 21 '14 at 10:35
  • Can I ask why u want to revert MP3 back to wav? – DarkBee Aug 21 '14 at 10:51
  • @DarkBee I am running speech recognition on the audio, the speech recognition software I am using only accepts wav audio, this is why I have to convert it. – Mr. JWolf Aug 21 '14 at 11:05
  • @Sam Both the in this current example both MP3 and wav is 44100 hz. Is there a way to make run slightly slower so it matches the original? – Mr. JWolf Aug 21 '14 at 11:08
  • One thing which annoys me alot, is when I run it through Audacity, I get the same result as when I run it through my own code, 13 min shorter. I have tested with multible files and all of them is shorter in Audacity. – Mr. JWolf Aug 21 '14 at 11:11

2 Answers2

1

I have passed the MP3 files through mp3val and the problem appears to be, not NAudio and NAudio.Lame, but the MP3 file itself.

The MP3 file contain errors!

The fix is then to make sure the MP3 files does not contain errors.

Mr. JWolf
  • 1,375
  • 2
  • 14
  • 33
0

MP3 files contains a sequence of MP3 frames.
when you have converted the MP3 to WAV, your wav player is reading the correct audio length.
Your original MP3 length was misinterpreted by your player
Some players don't read the MP3 audio length correctly which is generally due to trimmed frames

Sam
  • 759
  • 1
  • 4
  • 10