Technical Data Stored in LAME MP3 Info Tags
The LAME tag—often referred to as the LAME Info header—is a
specialized metadata block embedded within the first audio frame of MP3
files encoded using the libmp3lame library. This article
outlines the precise technical data stored within this tag, detailing
how it preserves encoder configurations, audio characteristics, and
playback instructions. Understanding these parameters is essential for
software developers and audiophiles, as players utilize this data to
calculate accurate track durations, achieve gapless playback, and
normalize volume levels.
Structural and Encoder Identification Data
The beginning of the LAME tag contains identifiers and version control markers that allow decoders to recognize the tag and understand how to parse it.
- Header Magic Bytes: The tag begins with the ASCII
string
LAME(orXingfor some Variable Bitrate files), which serves as a signature for decoders to identify the presence of the info block. - LAME Version: A 9-byte string specifying the exact
version of the encoder used (e.g.,
LAME3.100). This is crucial for decoders to apply version-specific workarounds for older encoder bugs. - Tag Revision: A 4-bit value indicating the revision version of the LAME tag structure itself.
Encoding Settings and Quality Parameters
The LAME tag archives the specific configuration settings used during the compression process, which can be useful for archiving and troubleshooting.
- VBR Method: A 4-bit identifier specifying the bitrate control mode used during encoding (such as Constant Bitrate (CBR), Average Bitrate (ABR), or various Variable Bitrate (VBR) methods like V0 or V2).
- Lowpass Filter Value: A 1-byte value indicating the frequency of the lowpass filter applied to the audio prior to encoding, represented in Hz (scaled).
- Quality Setting: Stores the internal quality
selection parameter (
-qvalue in LAME, ranging from 0 to 9) and the VBR quality level. - Stereo Mode: Details the channel configuration used during encoding, such as Stereo, Joint Stereo (MS/IS), Dual Channel, or Mono.
Gapless Playback Metadata
MP3 compression naturally introduces silence at the beginning and end of an audio stream due to filter bank delays and frame padding. The LAME tag solves this issue by storing exact sample counts.
- Encoder Delay: A 12-bit value representing the number of silent samples added to the start of the audio file by the encoder’s internal processing filters (typically 576 samples).
- Encoder Padding: A 12-bit value representing the number of silent samples added to the end of the final MP3 frame to ensure the stream aligns with the fixed MP3 frame size.
By reading the delay and padding values, modern audio players can discard these silent samples dynamically, enabling seamless, gapless transitions between tracks.
Audio Characteristics and ReplayGain
To ensure consistent volume levels across different audio tracks without altering the underlying audio data, the LAME tag stores normalization metadata.
- ReplayGain Radio (Track) Gain: Stores a volume adjustment value (in decibels) to normalize the subjective loudness of the individual track to a target level.
- ReplayGain Audiophile (Album) Gain: Stores a volume adjustment value to normalize the loudness of an entire album while preserving the relative volume differences between tracks.
- Peak Signal Amplitude: Stores the absolute peak level of the uncompressed audio signal. Players use this value to prevent digital clipping when applying ReplayGain adjustments.
File Verification and Size Metrics
To assist decoders in fast seeking and file integrity verification, the tag includes physical data metrics.
- Music Length: A 4-byte integer recording the exact size of the actual MP3 audio stream in bytes (excluding the ID3 tags and the LAME header itself).
- Music CRC: A 2-byte Cyclic Redundancy Check (CRC-16) checksum of the entire audio stream, allowing players to verify if the audio data has been corrupted.
- Tag CRC: A 2-byte CRC checksum of the LAME tag itself to ensure the metadata block has not been altered or corrupted.