View Full Version : LAME 320 parameters
sirt
19th July 2013, 13:29
Hello,
I'm just wondering about some LAME 320 parameters. Sometimes I use EAC to extract audio data from my personal cds and I use this command-line :
-b 320 -h --add-id3v2 --ignore-tag-errors --ta "%a" --tt "%t" --tg "%m" --tl "%g" --ty "%y" --tn "%n" %s %d
If I check a compressed file with mediainfo, the following informations about compression are given :
-m j -V 4 -q 2 -lowpass 20.5
But when using Audacity, LAME 320, and after having checked a compressed file with Mediainfo, I obtain the following :
-m j -V 4 -q 3 -lowpass 20.5
As a consqeuence, what would be the difference betwen -q 2 et -q 3 while using LAME 320 kbps ?
detmek
19th July 2013, 14:38
Take a look here (http://www.hydrogenaudio.org/forums/index.php?showtopic=101132&st=0&start=0).
LoRd_MuldeR
19th July 2013, 15:39
-q controls the algorithm quality. It is a "quality vs. speed" option. It does not effect the bitrate, but my squeeze out some more quality at the same size/bitrate.
-V controls the quality level in VBR mode. It is a "quality vs. file size" option. AFAIK, this option does not apply to bitrate-based modes (ABR and CBR) at all.
I don't know why you see a "-V4" parameter at all, when using "-b 320". But even at the maximum possible bitrate (in MP3 format) of 320 kbit/s, the algorithm quality (-q) may still make a difference. But I would assume the difference is much smaller than at lower bitrates...
(BTW: "-h" is an alias for "-q 2")
See also:
http://lame.cvs.sourceforge.net/viewvc/lame/lame/doc/html/detailed.html
LoRd_MuldeR
19th July 2013, 15:49
I don't know why you see a "-V4" parameter at all, when using "-b 320". But even at the maximum possible bitrate (in MP3 format) of 320 kbit/s, the algorithm quality (-q) may still make a difference. But I would assume the difference is much smaller than at lower bitrates...
After thinking about this a bit more, it becomes clear:
LAME uses VBR mode (with "-V 4") by default. In VBR mode (when neither "--abr" or "--cbr" was set), "-b" only specifies the lower bitrate limit, not the target bitrate. Though, forcing the lower bitrate limit to 320 kbit/s (the maximum in MP3 format!) makes VBR meaningless and you effectively get "--cbr -b 320", I think.
This should also show up in the VBR histogram LAME prints out. You'll probably see 100% at the "320 kbps" bin and 0% at all others ;)
sirt
10th August 2013, 08:12
Thanks for your detailled answers. In fact, after reading the detmek linked page, it looks like, when encoding to 320, '-q 2' or '-q 3' are basically the same thing. Moreover, it seems -h (or -q 2 if you prefer) is recommanded because it is a good compromise. But, what if I use -b 320 -q 0, isn't that the highest quality you can get with Lame regarding its algorithm ?
But, I think no one would be able to see the difference between -q 0 and -q 2, so what is the point of the first one ?
LoRd_MuldeR
19th August 2013, 20:26
Thanks for your detailled answers. In fact, after reading the detmek linked page, it looks like, when encoding to 320, '-q 2' or '-q 3' are basically the same thing. Moreover, it seems -h (or -q 2 if you prefer) is recommanded because it is a good compromise.
For CBR/ABR mode, all "-q" values use different algorithms. And, according to the docs, "-q 3" is the recommended compromise now (and the default).
But for the (new) VBR mode, there is only the "good" (-q 0 to -q 4) and the "not so good" (-q 5 to -q 9) algorithm. That's why MediaInfo reports either "-q 0" or "-q 5" for VBR files.
See here:
http://lame.cvs.sourceforge.net/viewvc/lame/lame/doc/html/detailed.html#q
But, what if I use -b 320 -q 0, isn't that the highest quality you can get with Lame regarding its algorithm ?
"-q" and "-b" are independent option. You can think of "-b" as the option that controls how much bitrate (file size) you are willing to spent. And of "-q" as the option that controls how much computation time you are willing to spent for using the available bits as efficiently as possible - maybe except that in VBR mode the "-q" option may also effect the encoder's bitrate choice.
So yes, with the combination of "-b 320" and "-q 0" you are using the maximum possible bitrate together with the maximum possible compression efficiency, which should give the highest quality you can get out of LAME.
Anyway: I think setting the minimum bitrate to 320 kbps with "-b 320" in VBR mode is kind of pointless. One the one hand, you use VBR mode. But on the other hand, you don't give the VBR algorithm any room to work. Thus, you could be using "--cbr -b 320" just as well, I think ;)
But, I think no one would be able to see the difference between -q 0 and -q 2, so what is the point of the first one ?
As always with those "speed -vs- quality" options:
The higher you push it, the smaller the additional gain becomes. So at some point it doesn't really make sense to use an even "slower" option, because the additional computation time isn't worth the very small quality gain. On the other hand, some people don't care about encoding speed and just use the slowest possible ("placebo") option. There may even be some "extreme" examples where the difference does matter, while the difference is negligible with most footage.
So, is using "-q 0" or "-q 1" reasonable for most users and most inputs? Probably not. But should those options be removed altogether? No, because some people may actually want to use them. And if it's only for testing/evaluation purposes.
(Another thing to consider is that the differences between the different "-q" values probably are more recognizable at lower bitrates. If you use 320 kbps anyway, the "-q" setting may not matter that much!)
hello_hello
20th August 2013, 01:21
I can't seem to create a CBR MP3 without MediaInfo displaying the -V encoder parameter no matter what I do. For a CBR encode (and maybe ABR) it always seems to be -V 4. It doesn't matter if you use --cbr in the command line. For example (foobar2000 command line):
Command line: -S --noreplaygain --cbr -b 128 - %d
Encoder settings: -m j -V 4 -q 3 -lowpass 17 -b 128
Command line: -S --noreplaygain -b 128 - %d
Encoder settings: -m j -V 4 -q 3 -lowpass 17 -b 128
Both of the above encodes resulted in a CBR MP3 at 128Kb/s. The output file sizes were identical down to the byte. So it seems if VBR or ABR aren't specified in some way, LAME defaults to using CBR encoding whether you use --cbr in the command line or not.
The way I read the LAME command line options, -b specifies the minimum bitrate in VBR mode, and the actual bitrate in CBR mode, so I gather from my test encodes a command line of "-b 128" is effectively the same as a command line of "--cbr -b 128".
It seems it's possible to use the -V parameter in combination with --cbr, even though I'm not sure it makes sense to do so:
Command line: -S --noreplaygain -V 2 --cbr -b 128 - %d
Encoder settings: -m j -V 2 -q 3 -lowpass 17 -b 128
The above still resulted in a 128kb/s CBR encode, and encoding speed was identical to using the same command line without -V 2, so I'm thinking if --cbr is specified, then the -V parameter is effectively meaningless. Why LAME prints -V 4 for CBR encoding be default, I'm not sure. Maybe I'm missing the obvious.
http://lame.cvs.sourceforge.net/viewvc/lame/lame/doc/html/detailed.html#q
--cbr Enforce constant bitrate encoding
This switch disables the VBR encoding. Examples:
lame -V 0 --cbr input.wav
Will encode at -b 128 (ignore completely -V and encode at default bitrate)
When I used the same command line as above without --cbr, the -V 2 parameter obviously then had an effect:
Command line: -S --noreplaygain -V 2 -b 128 - %d
Encoder settings: -m j -V 2 -q 0 -lowpass 18.5 --vbr-new -b 128
The above encode was VBR with a minimum bitrate of 128 and a maximum of 184.
Anyway.... the original question was regarding the difference between -q 2 and -q 3. I guess it's been explained that "-h" = "-q 2" and without it the default is "-q 3".
Even though the links supplied in earlier posts seem to indicate there's no difference between -q 2 and -q 3, the difference in encoding speed between them would seem to indicate otherwise (same CBR of 128). A test encode using -q 3 resulted (according to foobar2000) in an encoding speed of around realtime x 34, or a total encoding time of 8 seconds. The same encode using -q 2 was around realtime x 25 and took 12 seconds. The -q 3 encode sat on the same encoding speed from start to finish, hardly fluctuating (34x). In contrast the -q 2 encode caused encoding speed to fluctuate (between 21x and 27x).
For the record:
-q 3: 8 seconds, realtime x34
-q 2: 12 seconds, realtime x 25 (roughly)
-q 1: 27 seconds, realtime x10
-q 0: 35 seconds, realtime x 8 (roughly)
The encoding speed when using -q 1 was pretty steady, whereas -q 0 caused encoding speed to fluctuate more, similar to the way it does with -q 2.
Standard -V encodes are faster than CBR. Using just -V 2 for the above encode took about 6 seconds at a pretty steady realtime x 44.
sirt
20th August 2013, 10:11
LoRd_MuldeR
Thank you for this huge post. It reminds me of everything you told me about x264 last year. I think the problem I encounter and that I still don't manage to solve can be summed up into one single question : when can one decide to use placebo settings (-q 0 ...) instead of standard (-q2 -q3) ? You may answer : when one "listens" differences compared to the lossless track or when a spectrum is complety distorted. But, it can happen one listen something and another one anything. Then a track encoded with -b 320 -q2 would be great for one and sounds crap for another one. Actually, it is similar to our discussion about psychovisual enhancement in x264. Excepted that if the distorsion is crude of course.
So let's say I rip a commercial CD with EAC into both FLAC and MP3 (-b 320 -q 2). How could compare lossless tracks and their lossy version ? I guess "listening" is an indicator, but what if I don't perceive any difference but, theoretically, there are effecive distorsions. Do you know a program that would allow me to drag a FLAC and one or several lossy encodes and compare them ?
hello_hello
Thank you again for this very usefull and instructive post. You mostly develop the gain or loss of speed between the different -q but you are not telling us if you noted a difference in term of quality or anything like this.
Groucho2004
20th August 2013, 11:01
So let's say I rip a commercial CD with EAC into both FLAC and MP3 (-b 320 -q 2). How could compare lossless tracks and their lossy version ? I guess "listening" is an indicator, but what if I don't perceive any difference but, theoretically, there are effecive distorsions. Do you know a program that would allow me to drag a FLAC and one or several lossy encodes and compare them ?
When you compare lossless and lossy files, listening is the only thing that makes sense because the psycho-acoustic algorithms of lossy encoders take advantage of shortcomings of the human ear - or rather the part of your brain that processes music/sound.
hello_hello
20th August 2013, 13:45
So let's say I rip a commercial CD with EAC into both FLAC and MP3 (-b 320 -q 2). How could compare lossless tracks and their lossy version ? I guess "listening" is an indicator, but what if I don't perceive any difference but, theoretically, there are effecive distorsions. Do you know a program that would allow me to drag a FLAC and one or several lossy encodes and compare them ?
The only test which means anything is the one which involves listening, as lossy compression by it's very nature changes the audio. If it changes it in ways you can't detect with your ears then it's doing it's job.
Maybe something for performing an ABX test would be what you need. The general idea of an ABX test would be to compare two audio samples (usually the original and an encoded version) to determine if you can reliably hear a difference between them.
There's a standalone program here for comparing audio and performing ABX tests:
http://web.archive.org/web/20070817111509/http://ff123.net/abchr/abchr.html
I'm not sure, but maybe you'll be able to tell me for certain.... have I mentioned foobar2000 at all yet? ;)
Here's the ABX Comparator plugin for foobar2000:
http://www.foobar2000.org/components/view/foo_abx
I've not watched it myself, but apparently this video shows you how to use it:
http://www.youtube.com/watch?v=jt7GyFW4hOI
hello_hello
Thank you again for this very usefull and instructive post. You mostly develop the gain or loss of speed between the different -q but you are not telling us if you noted a difference in term of quality or anything like this.
I didn't, but I was really more curious regarding the speed differences between -q settings so I just opened foobar2000 and converted the first file in it's playlist for testing, which happened to be an existing MP3.
Plus to be honest I mainly use my PC speakers for everything, including watching movies, and while they're fairly good quality (THX Certified), I'm not sure they'd be ideal for ABX testing.
I do have some very nice headphones somewhere, but I'd need to find them.....
I can't say I've ever fussed over MP3 quality to that extent anyway for several reasons.
LAME encoded MP3s sound very good. The standard VBR presets will result in a "transparent" encode (with maybe the rare exception).
Most of my MP3 listening is using portable audio players, headphones, and often in environments with more than an ideal amount of background noise, so that all adds up to degrading the audio far, far more than encoding to MP3 on it's own ever will.
The MP3s are for carrying around. The FLAC versions are the originals. Therefore the MP3s are disposable. They don't need to be perfect, and while perfect would be ideal, 99% of perfect will do.
And I'm probably old enough to view an ipod full of MP3s with a slightly different perceptive to some... I've owned a Sony Walkman cassette player. ;) I've probably still got a Walkman CD player or two floating around somewhere. The first one wouldn't play burned audio CDs very well...... remember those? :)
Groucho2004
20th August 2013, 14:17
LAME encoded MP3s sound very good. The standard VBR presets will result in a "transparent" encode (with maybe the rare exception).
Most of my MP3 listening is using portable audio players, headphones, and often in environments with more than an ideal amount of background noise, so that all adds up to degrading the audio far, far more than encoding to MP3 on it's own ever will.
The MP3s are for carrying around. The FLAC versions are the originals. Therefore the MP3s are disposable. They don't need to be perfect, and while perfect would be ideal, 99% of perfect will do.
+1 :goodpost:
LoRd_MuldeR
20th August 2013, 20:20
So let's say I rip a commercial CD with EAC into both FLAC and MP3 (-b 320 -q 2). How could compare lossless tracks and their lossy version ? I guess "listening" is an indicator, but what if I don't perceive any difference but, theoretically, there are effecive distorsions. Do you know a program that would allow me to drag a FLAC and one or several lossy encodes and compare them ?
"ABX" (or "double-blind test") is the keyword. You'll find a bunch of tools on the net...
http://en.wikipedia.org/wiki/ABX_test
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.