问题
My Problem is to get ACTUAL DATA of a mp3 frame. For this I have used NAudio and get RawData but I think in the RawData property, it returns all the bytes of the frame including header and side information.
Code is given below:
private void button1_Click(object sender, EventArgs e)
{
Mp3FileReader reader = new Mp3FileReader("file.mp3");
Mp3Frame mp3Frame = reader.ReadNextFrame();
byte [] FrameByteArray = mp3Frame.RawData;
BitArray bits = new BitArray(FrameByteArray);
Console.Write(mp3Frame.RawData.Length);
foreach (bool b in bits)
{
if (b == true)
{
Console.Write(" 1");
}
else
{
Console.Write(" 0");
}
}
reader.Close();
}
it returns all frame data in bits including header and side information. But I only need actual data of every frame without header and side information.
Can anyone help??
回答1:
NAudio can find the MP3 frame for you, but it does not do any deeper level parsing of the contents beyond identifying some basic information such as sample rate, channel mode etc.
If you need to explore more deeply then you'll need to familiarise yourself with the internal structure of an MP3 frame. In particular, see if you can get hold of these documents:
- MPEG 1 Specification (ISO/IEC 11172-3).
- MPEG 2 Specification (ISO/IEC 13818-3).
This article on codeproject would be a good place to start (follow the links at the bottom). If you want C# code that contains a deeper understanding of the MP3 frame format, then you can explore the source code for NLayer
来源:https://stackoverflow.com/questions/18865203/how-to-trim-header-and-side-information-of-mp3-frame-using-naudio-and-c-sharp