Difference between revisions of "LAME -q switch"

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
m (External links: link formatting fixes)
 
(12 intermediate revisions by 6 users not shown)
Line 1: Line 1:
=Internal Variables=
+
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.
  
 +
==Equivalences==
 +
===CBR===
 +
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===
 +
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.
 +
 +
==Effects==
 +
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.
 
{| border=1 class="wikitable" style="text-align:center"
 
{| border=1 class="wikitable" style="text-align:center"
! -q n !! huffman search !! full_outer_loop !! sv_qnt.substep_shaping !! subblock gain !! noise shaping !! amplification !! stopping !! description
+
! -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   || 1 || 2 ||  1 || 1 || 2 || 1 || align="left" | Use slowest & best possible version of all algorithms.
+
| 0 || Best   || Yes || 2 ||  1 || Yes || 2 || 1 || align="left" | Use all the slowest parameters/algorithms that are available.
 
|-
 
|-
| 1 || best   || 0 || 2 ||  1 || 1 || 2 || 1 ||
+
| 1 || Best   || No || 2 ||  1 || Yes || 2 || 1 ||
 
|-
 
|-
| 2 || best   || 0 || 2 ||  1 || 1 || 1 || 1 || align="left" | Recommended.  Same as -h. -q 0 and -q 1 are slow and may not produce significantly higher quality.
+
| 2 || Best   || No || 2 ||  1 || Yes || 1 || 1 || align="left" | Same as -h. Higher quality than the default -q3. -q2 was the default in older versions of LAME.
 
|-
 
|-
| 3 || best   || 0 || ? ||  1 || 1 || 1 || 1 || align="left" | Default value. Good speed, good quality.
+
| 3 || Best   || No || ? ||  1 || Yes || 1 || 1 || align="left" | Default value. Good speed, good quality. Lower values of -q may not produce significantly higher quality.
 
|-
 
|-
| 4 || best   || 0 || ? ||  1 || 1 || 0 || 0 ||
+
| 4 || Best   || No || ? ||  1 || Yes || 0 || 0 || align="left" | Optimal speed/quality. Usually produce less distortion at high frequencies than all other values of -q, except 5-6.
|-
+
| 5-6 || normal || 0 || ? ||  1 || 1 || 0 || 0 ||
+
|-
+
| 7-8 || normal || 0 || ? || -1 || 0 || 0 || 0 || align="left" | Same as -f. Very fast, ok quality. (psycho acoustics are used for pre-echo & M/S, but no noise shaping is done.
+
|-
+
| 9 || normal || 0 || ? || -1 || 0 || 0 || 0 || align="left" | Disables almost all algorithms including psy-model. Poor quality.
+
|}
+
 
+
= VBR =
+
 
+
{| border=1 class="wikitable"
+
! -q n !! description
+
 
|-
 
|-
| 0-4 || Default value. Use the best algorithm.
+
| 5-6 || Normal || No || ? ||  1 || Yes || 0 || 0 || align="left" | Almost the same as -q4.
 
|-
 
|-
| 5-6 || Use the not so good algorithm
+
| 7-8 || Normal || No || ? || -1 || No || 0 || 0 || align="left" | Same as -f. Very fast, OK quality. Psychoacoustics are used for pre-echo and mid/side stereo, but no noise-shaping is done.
 
|-
 
|-
| 7-9 ||  
+
| 9 || Normal || No || ? || -1 || No || 0 || 0 || align="left" | Disables almost all algorithms including psy-model. Extremely fast. OK quality.
 
|}
 
|}
  
=Observations=  
+
==External links==
* -q 5-6 Output Same Results. LAME header will indicate the different quality parameter. But the files are otherwise a perfect match.
+
* [http://lame.cvs.sourceforge.net/viewvc/lame/lame/doc/html/detailed.html#q Current documentation]
* -q 7-8 Is always mapped to -q 7 and thus outputs identical files, including the LAME header.
+
* [http://www.hydrogenaud.io/forums/index.php?showtopic=101132 Research & discussion that led to this summary] (2013)
* -q 9 Output is same as -q 7. But official doc describes it as a different quality. LAME header will be different for CBR/ABR and identical for VBR.
+
* [http://www.hydrogenaud.io/forums/index.php?showtopic=107424 More discussion mainly re: ABR] (2014)

Latest revision as of 16:52, 7 November 2014

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.

Equivalences

CBR

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

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.

Effects

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.
1 Best No 2 1 Yes 2 1
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.

External links