Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: MP3 Header in LAME (Read 2240 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

MP3 Header in LAME

Hi,

I am trying to encode a raw pcm stream as mp3 with LAME before entering it into an FLV container. To encode the raw pcm stream as mp3, I am using the following functions: 
1.lame_encode_buffer(...)
2.lame_encode_flush(...)

In both these functions, the mp3 encoded samples are stored in buffers of type unsigned char. My question(s):

1. Is it correct to assume that the first 32 bits of the buffer would be the MP3 header? In other words does the MP3 "frame" as output by the above function contain the header as well? I tried to output the contents of the mp3 buffer byte by byte. I see that most frames have 255 as the first element but some do not.

2. If the MP3 header is not part of the first 32 bits, how do I write the header? What is a Xing header? Is it a version of the MP3 header or ID3v2 tag?

3. Using the LAME API, how do we find the bitrate of the file?

I have been scratching my head on these issues for some time and some help would be most welcome.