is Naudio the library to split mp3 files?

Mar 14, 2011 at 5:59 PM

I am looking for a library to offer me an option to cut audio files. I want to give a parameter, such time start and time end and then cut this  part, but I don't know how to start.

Coordinator
Mar 16, 2011 at 6:17 PM

NAudio doens't have a quick and easy class for this. If you ask on StackOverflow I'm sure they would point you in the right direction.

Having said that, NAudio can parse MP3 files and read out blocks, so you can use it to cut MP3 files if you understand how MP3s are structured.

Mark

Mar 28, 2011 at 3:04 PM

hi,

I have read the some docs for mp3 and found out that each mp3 frame corresponds to 26ms of audio regardless of bit rate or sample rate(See here: http://oreilly.com/catalog/mp3/chapter/ch02.html  the Frames per Second section at the very end of the page). So what you can do is skip the frames till you reach the start time and save the frames from that point till the end time.

That is lets say your start time is 20 seconds 150 milliseconds. Convert it to milliseconds: 20150 ms. Now you need to skip: 20150 / 26 frames = 775 frames. So after skipping 775 frames, you reach the start time. Apply the same logic till you reach the end-time, but this time instead of skipping the frames, save them.

Hope this helps.

Mar 28, 2011 at 3:10 PM

thx!

Jun 8 at 5:27 AM
Arnolin wrote:
hi, I have read the some docs for mp3 and found out that each mp3 frame corresponds to 26ms of audio regardless of bit rate or sample rate(See here: http://oreilly.com/catalog/mp3/chapter/ch02.html  the Frames per Second section at the very end of the page). So what you can do is skip the frames till you reach the start time and save the frames from that point till the end time. That is lets say your start time is 20 seconds 150 milliseconds. Convert it to milliseconds: 20150 ms. Now you need to skip: 20150 / 26 frames = 775 frames. So after skipping 775 frames, you reach the start time. Apply the same logic till you reach the end-time, but this time instead of skipping the frames, save them. Hope this helps.
hi, Arnolin,
I have read the docs at the website which you listed, but seems that the 26ms for each frame is for MPEG-1 file, not MP3. So are they the same?
Jun 9 at 5:23 PM
huzq: MP3 denotes MPEG-1 Layer III encoding, which is defined in ISO 11172-3. The standard calls for equal length frames (counted in samples) for a given layer (MP3 is almost always 1152 per frame). At 44.1kHz, MP3 is typically 26.122ms per frame.

Please note, if you're trying to cut frames out of a file, Layer III may place some audio data in the preceding frame as part of a psuedo-VBR scheme (look up: bit reservoir). Gotta make life more fun for everyone, right?