HydrogenAudio

Lossy Audio Compression => MP3 => MP3 - Tech => Topic started by: ssriram on 2013-02-18 12:26:42

Title: MP3 Header in LAME
Post by: ssriram on 2013-02-18 12:26:42
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.