how to trim header and side information of mp3 frame using Naudio and c#

冷暖自知 提交于 2020-01-25 11:51:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!