LAME -q switch
From Hydrogenaudio Knowledgebase
When using LAME from the command line, the switch -q (quality) can be added in either VBR or CBR mode to alter various parameters used when encoding, which are predicted (at least in theory) to affect the quality of the output MP3 stream.
Some values of -q seem to produce equivalent files, at least in terms of the audio itself.
- -q5 and -q6 output identical results. LAME's header will indicate the different quality parameter, but the files, including the actual audio, are otherwise a perfect match.
- -q8 is always mapped to -q7 and thus outputs identical files, including the header.
- -q9 outputs the same file as -q7 and -q8, although the official documentation describes it as a different quality. The LAME header will be different for CBR/ABR and identical for VBR.
VBR encoding modes take some different code paths and ignore some of the listed values. In particular, the ten values of -q are mapped to just 3 values under VBR as of 3.98 and later:
- -q7 to -q9 are mapped to -q7. This level uses a psymodel but does not calculate quantisation noise when encoding: it takes a quick guess.
- -q5 and -q6 include all features of -q7, calculate and consider actual quantisation noise, and additionally enable subblock gain.
- -q0 to -q4 include all features of higher numbers and additionally use the best search when applying Huffman coding.
This table documents the parameters that are affected by the value assigned to -q. These are most relevant to CBR for the reasons noted above.
|-q n||Huffman coding search||Use full outer loop for Huffman encoding||sv_qnt.substep_shaping||Subblock gain||Noise-shaping||Amplification||Stopping||Description|
|0||Best||Yes||2||1||Yes||2||1||Use all the slowest parameters/algorithms that are available.|
|2||Best||No||2||1||Yes||1||1||Same as -h. Higher quality than the default -q3. -q2 was the default in older versions of LAME.|
|3||Best||No||?||1||Yes||1||1||Default value. Good speed, good quality. Lower values of -q may not produce significantly higher quality.|
|4||Best||No||?||1||Yes||0||0||Optimal speed/quality. Usually produce less distortion at high frequencies than all other values of -q, except 5-6.|
|5-6||Normal||No||?||1||Yes||0||0||Almost the same as -q4.|
|7-8||Normal||No||?||-1||No||0||0||Same as -f. Very fast, OK quality. Psychoacoustics are used for pre-echo and mid/side stereo, but no noise-shaping is done.|
|9||Normal||No||?||-1||No||0||0||Disables almost all algorithms including psy-model. Extremely fast. OK quality.|