I am very new to audio or mp3 stuff, was looking for a way to have a feature to split an mp3 file in C#, asp.net. After googling for a good 3-day without much of a great help, I am hoping that somebody here can point me to a right direction.
Can I use NAudio to accomplish this? Is there any sample code for that? Thanks in advance.
My final solution to split mp3 file in c# is to use NAudio. Here is a sample script for that, hope it helps someone in the community:
Thanks to Mark Heath's suggestion for this.
The namespace required is NAudio.Wave.
The previous answers helped me get started. NAudio is the way to go.
For my PodcastTool I needed to to split podcasts at 2 minute intervals to make seeking to a specific place faster.
Here's the code to split an mp3 every N seconds:
An MP3 File is made up of a sequence of MP3 frames (plus often ID3 tags on the beginning and end). The cleanest way to split an MP3 file then is to copy a certain number of frames into a new file (and optionally bring the ID3 tags along too if that is important).
NAudio's
MP3FileReader
class features aReadNextFrame
method. This returns anMP3Frame
class, which contains the raw data as a byte array in theRawData
property. It also includes aSampleCount
property which you can use to accurately measure the duration of each MP3 Frame.these would be helpful Alvas Audio (commercial) and ffmpeg