Man, I haven’t used LAME in maybe 2 decades. And so, I had a use case for it again and that lead me down a bit of a rabbit-hole. Ultimately, the short version is, LAME has a bug with CBR recordings where specifying -q0 through -q3 can cause a LOSS of quality!
So, they recommend using -q4 to avoid a quality loss with CBR files (and ABR; VBR is unaffected).
The official bug report is available here: https://sourceforge.net/p/lame/bugs/516/
Based on the information that report, I patched lame in the following way. Only one file was modified, lame.c:
@@ -427,7 +427,11 @@
case 3:
if (cfg->noise_shaping == 0)
cfg->noise_shaping = 1;
+ if (cfg->vbr == vbr_off || cfg->vbr == vbr_abr) {
+ cfg->noise_shaping_amp = 0;
+ } else {
cfg->noise_shaping_amp = 1;
+ }
cfg->noise_shaping_stop = 1;
if (cfg->subblock_gain == -1)
cfg->subblock_gain = 1;
@@ -440,7 +444,11 @@
cfg->noise_shaping = 1;
if (gfc->sv_qnt.substep_shaping == 0)
gfc->sv_qnt.substep_shaping = 2;
+ if (cfg->vbr == vbr_off || cfg->vbr == vbr_abr) {
+ cfg->noise_shaping_amp = 0;
+ } else {
cfg->noise_shaping_amp = 1;
+ }
cfg->noise_shaping_stop = 1;
if (cfg->subblock_gain == -1)
cfg->subblock_gain = 1;
@@ -453,7 +461,11 @@
cfg->noise_shaping = 1;
if (gfc->sv_qnt.substep_shaping == 0)
gfc->sv_qnt.substep_shaping = 2;
+ if (cfg->vbr == vbr_off || cfg->vbr == vbr_abr) {
+ cfg->noise_shaping_amp = 0;
+ } else {
cfg->noise_shaping_amp = 2;
+ }
cfg->noise_shaping_stop = 1;
if (cfg->subblock_gain == -1)
cfg->subblock_gain = 1;
@@ -466,7 +478,11 @@
cfg->noise_shaping = 1;
if (gfc->sv_qnt.substep_shaping == 0)
gfc->sv_qnt.substep_shaping = 2;
+ if (cfg->vbr == vbr_off || cfg->vbr == vbr_abr) {
+ cfg->noise_shaping_amp = 0;
+ } else {
cfg->noise_shaping_amp = 2;
+ }
cfg->noise_shaping_stop = 1;
if (cfg->subblock_gain == -1)
cfg->subblock_gain = 1;
This allows you to use -q0, -q1, -q2 or -q3 with CBR and still get the rest of the settings that would apply in those cases, without forcing you to use -q4.
It has the benefit of also allowing you to keep using VBR to the highest quality.
Both version 3.101 and 4.0 are included in the zip file. You do not need any DLL files, it is statically compiled which means the DLL files are baked-in to the exe essentially.
Download here: lame-3.101-and-4.0-q0-patched.zip






