Convert big mp3 files to wav timing issue - c#

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?

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.

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

Related

AviFile Library creates avi bigger than 2 GB- not useable

I am using the AviFile Library to make a avi video from Bitmaps, comming from Kinect. The file size gets really high, and over 2 GB I cannot open these files anymore. I will have to compress these files. Does anyone know a tool how I can compress it or a better lib than AviFile?
Kind regards
Alexander Ziegler
Ok, I have done a work around! The biggest problem was to handle the huge amount of images comming from the kinect. With compressing it was not possible to write them to file (--> out of memory). So I write them just into a file (during recording) as bytes. After recording I read them out, compress them and save them to avi (the files getting much smaller about 100 MB). Thanks for every comment

Rendering a wav file from wav files in c#

I got some short .wav files and after i get sequence how it should be played in time I need to "render" a one wav file which will contain that .wav files. I know I can append it but the problem is that some wav files should be played at one time, and also it need to be in rhythm (exact spaces).
How?
You will need to use some libraries like ffmpeg or SoX to do this.
Reference: http://ffmpeg.org, http://sox.sourceforge.net

MP3 splitting - output files don't have correct file info

I have successfully used code from following SO question:
NAudio to split mp3 file to split some test MP3s.
The input file has constant bitrate 198kbps. The debug shows, that splitting occurs at correct time (each 120 seconds).
The problem is, that Windows and audioplayer show incorrect information about the files. The bitrate vary and the file duration too.
What I need to do, to correct the ingfo in output files?

Combining two audio files in C#

There are 2 audio ( mp3 or wav) files. The first file has the voice of me, the second one has the voice of my friend. Each of them has 10 seconds duration.
I want to combine them to get one file that also should have 10 seconds duration.
What are the tools or utilities I should use to solve this issue?
UPDATE: I used lame.exe, but it concatenated them and created the file of 20 seconds duration.
This might do the trick.
My WAVFile class supports 8- and 16-bit audio, mono or stereo. One of
its special features is a method that will mix WAV audio files
together, so that the audio from each source WAV file will be heard
simultaneously.
Note: In the above paragraph, My refers to the author of the class, not to myself.
Check out NAudio tutorial: Mixing multiple wave files together in real time.

How can I split an mp3 file into several individually playable parts?

How can I break a large mp3 file into one or more mp3 files, and still have each part playable in a media player?
It's probably not going to be super easy to break an mp3 file into separate playable mp3 files. There is header information in the mp3 file that you will need to include in all of the split-up files. You might need to get a book or look for a file spec on mp3s, so you know what you're dealing with.
You might be best-off looking for a library that can deal with mp3 files, rather than trying to do it yourself with a FileStream.
Actually, breaking a MP3 file into seperate playable MP3 files is quite easy. A MP3 file consists of a lot of individual frames of iirc 1500bytes, where each has it's own header. Invalid data will be ignored by the player.
But, it would be a lot better if you where to split your files on frame boundaries, creating correct mp3 files. More info on the frame header can be found on this site: http://www.mp3-tech.org/programmer/frame_header.html
Please also consider the possibility that the music is prepended and/or appended with various meta tags, like ID3, APE and lyrics.

Categories