
How does an mp3 file work?

What is the structure of an mp3?

MP3 file is composed of frame (frame), frame is the smallest composition unit of MP3 file. MP3 full name should be MPEG1 Layer 3 audio files. MPEG
(Motion Picture Experts Group) translates into Chinese as Moving Picture Experts Group, and refers specifically to moving video and audio compression standards.
MPEG1 standard, also known as MPEG audio layer, which is divided into three layers based on compression quality and encoding complexity, namely,
Layer-1, Layer2 and Layer3, which correspond to the three sound files of MP1, MP2 and MP3 respectively, and use different
levels of audio files according to different purposes. The higher the MPEG audio encoding level, the more complex the encoder and the higher the compression ratio. The compression ratios of MP1 and MP2 are 4:1 and
6:1-8:1 respectively, while the compression ratio of MP3 is as high as 10:1-8:1. 12:1, meaning one minute of CD-quality music requires 10MB
of storage space without compression, but only about 1 MB after MP3 compression encoding. However, MP3 uses a lossy compression method for audio signals.
Low sound distortion, MP3 adopts “sensory coding technology”, that is, when encoding, the audio file is first analyzed for frequency spectrum, and then the noise level is filtered by a filter, and then each bit remaining is sparse and arranged by quantization, and finally form an MP3 file with a higher compression ratio, and make the file
compressed achieve a sound effect closer to the original sound source when played back.
2. The complete structure of the file
MP3 The MP3 file is roughly divided into three parts: TAG_V2 (ID3V2), Frame, TAG_V1 (ID3V1) ID3V2
contains
information like author, composer, album, etc. The length is not fixed, which expands the information volume of ID3V1.
frame
… Frame A series
of frames, the number is determined by the file size and the length of the frame
. The length of each FRAME may not be fixed, or it may be fixed. It is determined by the bit rate. Each FRAME is divided into two parts: frame header and data entity. The frame header records information such as bit rate, sample rate, and mp3 version, and each frame is independent of each other. ID3V1 contains information like author, composer, album, etc. ., and the length is 128BYTE. 3. MP3 Frame Format 1. Frame Header Format The frame header is 4 bytes long. For fixed bitrate MP3 files, the frame header format of all frames is the same. The data structure is as follows: typedef FrameHeader { unsigned int sync: 11; // unsigned synchronization information int version: 2; // version



