Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Mp3 setting, command: -q (Read 14450 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Mp3 setting, command: -q

Hi, I don´t understand what´s up, or what´s wrong with the mp3 command line -q. With -q 9 (Faster Quality) i get more quality, a large file and more frecuencies that -q 0 (Higher Quality) setting. With -q 0  the SPEK shows a lower quality and a smaller file.

For example i always use this setting: -m s -V 4 -q 9 -lowpass 20.5 ___ In SPEK the spectre is FULL and all fill

But too many people uses: -m s -V 4 -q 0 -lowpass 20.5 ____ In SPEK the spectre is more EMPTY and not so fill

Then, which one setting can get more or the highest quality SOUND (not encode or compression) ? I mean that not care the size of file, only the best quality of sound.

The official instruction of command line options of LAME Encoder:

=======================================================================
Algorithm quality selection
=======================================================================
-q n

Bitrate is of course the main influence on quality. The higher the bitrate,
the higher the quality. But for a given bitrate, we have a choice of algorithms
to determine the best scalefactors and Huffman coding (noise shaping).

For CBR, ABR and --vbr-old modes, the following table applies

-q 0            Use the best algorithms (Best Huffman coding search, full outer
                loop, and the highest precision of several parameters).
-q 1 to -q 4    Similar to -q 0 without the full outer loop and decreasing
                precision of parameters the further from q0. -q 3 is the default
-q 5 and -q 6   Same as -q 7, but enables noise shaping and increases subblock
                gain
-q 7 to -q 9    Same as -f. Very fast, OK quality. Psychoacoustics are used for
                pre-echo and mid/side stereo, but no noise-shaping is done.

For the default VBR mode since LAME 3.98, the following table applies

-q 0 to -q 4    include all features of the other modes and additionally use
                the best search when applying Huffman coding.
-q 5 and -q 6   include all features of -q7, calculate and consider actual
                quantisation noise, and additionally enable subblock gain.
-q 7 to -q 9    This level uses a psymodel but does not calculate quantisation
                noise when encoding: it takes a quick guess.







Re: Mp3 setting, command: -q

Reply #1
You can get the best quality by not using the q flag at all.

Re: Mp3 setting, command: -q

Reply #2
Please stop using SPEK to determine the "quality" of your files. You hear with your ears, not your eyes.

Re: Mp3 setting, command: -q

Reply #3
I think the idea is that with -q 0, the encoder dedicates more attention to the frequencies you actually could potentially hear better, hence the lack of higher frequencies that you notice in spectrograms.

However, I'd like to point out a couple of things...

First of all, you keep mentioning "quality" as if that were determined by the spectrogram of an audio file. This is not the case at all -- rather, the only thing that matters is how the file actually sounds. If there's no clearly discernible and obvious lossy compression artefacts (which there almost certainly won't be at a high enough bitrate setting for the modern versions of LAME), then you compare the MP3 with the lossless original via a double-blind test. The usual one is ABX. If with double-blind testing you can't tell the MP3 and the lossless original apart, they (the lossless original and the MP3) are the same quality, regardless of whatever q parameter was chosen.

Secondly, as the documentation mentions ("Bitrate is of course the main influence on quality.") if you use a high enough bitrate setting (something like 320kbps CBR or V0 if you use VBR), the choice of q will almost be certainly irrelevant anyway, so it's best to just let LAME use what it thinks is best.
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

Re: Mp3 setting, command: -q

Reply #4
-q changes the noise shaping algorithm from the documentation and old posts. Different lame version did different things and also vbr-new /  old use -q different..

Interestingly I found using -q7 or -f can help with long standing problem samples that have a ringing or  distortion issues.  Its also very fast.  for very high bitrates using -f may also be an advantage as it use a less aggressive noise shaping  / psymodel . That can in theory help with odd problem cases or even post-processing..   For vbr[new] , q4..0 are the same thing, 5..7 are different.

For me personally, -f or -q7 all the way esp with bitrate of 150k +.

Re: Mp3 setting, command: -q

Reply #5
Is no one else going to point out that using -m s could lower sound quality?

Re: Mp3 setting, command: -q

Reply #6
The older (slower) method / psymodels still exist in v3.100 like in lame 3.90 etc ..

For vbr,

Vx --vbr-old -q2 (v3.90..3.93)
Vx --vbr-old -q3 (v3.96..3.97)


cbr,

-b128 -q2 (v3.90..3.93)
-b128 -q3 (v3.96..3.100)

Re: Mp3 setting, command: -q

Reply #7
Please stop using SPEK to determine the "quality" of your files. You hear with your ears, not your eyes.
It´s too difficult at that level be able to differentiate thouse fines and weaks frecuencies. Same as Doble Blind metod, it´s complicate. You could differenciate between .wav and mp3 or an mp3 128 kbps and 320 kbps, but more than that, i don´t think so.

Re: Mp3 setting, command: -q

Reply #8
I think i understand what Huffman coding (noise shaping) means... For Huffman coding (noise shaping) -q 0 command is talking about to get better sound quality eliminating or taking off the noise in the middle frecuencies of response curve of sound´s spectre.
And he wants we understand that your method could get the better sound quality with less noise (noise shaping method)... but i don´t think so !! i think that´s not right at all...

I understood... with -q 9 in comand line tab it gets betters armonics and more noise too, it will be a large file and SPEK wil represente it like a more color´s frecuencies of spectre. Finally more quality of sound (with noise, of couse), but it would be same as the original .wav file.

A command line with -q 0 uses an complex algorithm method that tries to eliminate "noise" an a few armonics frecuencies with him too... That´s why SPEK shows less color´s frecuencies and the file is smaller too... and the eliminated noise of mp3 should be less than the original .wav file.

In final thoughts -q 9 would o should be better (sound quality + noise + large file) than -q 0.

Creo que ya entendí qué significa el Huffman coding (noise shaping). Este método, que sería al usar el comando -q 0, trata de mejorar la calidad de sonido quitándole ruido al mismo, principalmente en las frecuiencias medias de la curva de respuesta en frecuencia de todo el espectro. Pero al quitarle el "ruido" también le quita algunas pocas frecuencias armónicas al sonido. Y de este modo ese sonido siempre tendrá menos calidad que el archivo. wav original. Yo no creo que eso mejore la calidad de sonido y creo que no es del todo cierto.

Con el comando -q 9 creo que se consigue mejores armónicos y más ruido también, el archivo .mp3 será más grande y el SPEK mostrará un espectro más coloreado también. Pero el archivo será y tendrá la misma calidad y ruido que el archivo .wav original.
El comando -q 0 sería todo lo contrario... para no escribir más... ja

En definitiva creo que -q 9 tiene o debería tener más calidad de sonido, más ruido también que si usamos el comando -q 0.

Re: Mp3 setting, command: -q

Reply #9
Is no one else going to point out that using -m s could lower sound quality?

- MS: Is the STEREO pure, the real dual channel mode. It is the real and original STEREO mode.

And try to stop or do not use the damm - MJ (fucking Join Setereo) comand... please.

Take a look at these:

Modes:
=======================================================================
-m m        mono
-m l       get only the left channel of a stereo signal for a mono output
-m r       get only the right channel of a stereo signal for a mono output
-m s        (forced) L/R stereo
-m j        joint stereo
-m f        forced mid/side stereo
-m d        dual (independent) channels. Its purpose was meant for dual language
            streams where only one of them should be decoded.
         Most decoders just decode them as a stereo stream.
-m a        Currently, a synonym of m j. (In older releases it selected
            different modes depending on the bitrate)

Re: Mp3 setting, command: -q

Reply #10
Quote
- MS: Is the STEREO pure, the real dual channel mode. It is the real and original STEREO mode.

And try to stop or do not use the damm - MJ (fucking Join Setereo) comand... please.
Do you know that conversion to  M/S or Joint Stereo is LOSSLESS and completely REVERSABLE?   

If you feed M/S (or JS) into a compression algorithm you usually get better compression (higher quality or smaller files).   Then, you reverse the M/S or JS after decompression to get stereo back.

Re: Mp3 setting, command: -q

Reply #11
The only Joint Stereo algorithm which is lossy is Intensity Stereo, and LAME doesn't even support compressing with that algorithm.

Re: Mp3 setting, command: -q

Reply #12
By using either -m s or -m f you will be forcing lame to use what will often be the less desirable encoding method. -m j allows lame to use whatever coding is best for that particular frame, giving the highest quality.

Re: Mp3 setting, command: -q

Reply #13
This is the correct help for that command:

Quote
-m x Channel modes
-m m mono
-m l get only the left channel of a stereo signal for a mono output
-m r get only the right channel of a stereo signal for a mono output
-m s forced L/R stereo
-m j / -m a   automatic switch between L/R and M/S stereo
-m f forced mid/side stereo
-m d dual (independent) channels.

MONO is the default mode for mono input files. If "-m m" is specified for a stereo input file, the two channels will be averaged into a mono signal. (Note: See comments about the -a switch for RAW PCM streams)

FORCED L/R STEREO encodes the left and the right signals independently, and gives more or less bits to each, depending on the currently available.

JOINT STEREO is the default mode of encoding. jstereo means the encoder can use (on a frame by frame basis) either L/R stereo or mid/side stereo. In mid/side stereo, the mid (L+R) and side (L-R) channels are encoded, and more bits are allocated to the mid channel than the side channel. When there isn't too much stereo separation, this effectively increases the bandwidth, so having higher quality with the same amount of bits.
Using mid/side stereo inappropriately can result in audible compression artifacts. Too much switching between mid/side and regular stereo can also sound bad. To determine when to switch to mid/side stereo, LAME uses a much more sophisticated algorithm than the one described in the ISO documentation.

FORCED MID/SIDE STEREO forces all frames to be encoded with mid/side stereo. It should only be used if you are sure every frame of the input file has very little stereo seperation.

DUAL CHANNEL mode is similar to encode the left and right as two mono signals. Its purpose was meant for Dual language streams where only one of them should be decoded. Most decoders just decode them as a stereo stream

 

Re: Mp3 setting, command: -q

Reply #14
@DVDdoug : While we both agree that joint stereo is the better method and that its the one that should be used with LAME, the implementation of joint stereo in lossy encoders is not mathematically equivalent to its simple stereo counterpart.
The "problem" here is that the audio is losslessly converted from LR to MS in the temporal domain, and then, the mid, and the side part are encoded by the algorithm.
Due to this, the "side" channel cannot be encoded as if it was an actual channel, but instead, the algorithm needs to be more careful, so that once decoded, that "side" can be used with the decoded mid without causing artifacts.

As I've posted in my previous reply, LAME knows this, and does take more care than what the original codecs did, and many here at hydrogenaudio know that the "bad press" for joint stereo was caused by a pirated frauhoffer encoder back in the late 90's and by early implementations of Xing encoder that used intensity stereo (and later it "abused" mid/side stereo and long blocks, compared to what LAME does today, but hey! it was 8x faster than the competition!).

Re: Mp3 setting, command: -q

Reply #15
 Suppose a high enough bitrate is used, Why is brute-force mid-side [ -mf ] a bad idea? I am betting this approach may be an advantage and be less prone switching errors.
Even if you had a sample with heavy stereo seperation, You would need to be on the cusp to hear artifacts. It would be more distorsion on the side - IF the encoder was already innacurate to actually umask itself.

Re: Mp3 setting, command: -q

Reply #16
I don't know with precision how the mid/side encoding is implemented in LAME, but mid/side encoding is only optimized if the stereo separation is not big. In fact, inverted signals (fake surround) can use values as much as double the full amplitude of the signal.
I'm not sure if it might have this amplitude limited, or what kind of artifacts it could generate.
I believe I'll make some tests now and check what it does..

Re: Mp3 setting, command: -q

Reply #17
Prescriptive warning:
This is not an analysis about audible quality, as that would require a blind test. The amplitude difference between signals doesn't translate to perceived quality.

The intention of this is to determine what kind of differences can appear when encoding with LAME forcing L/R or forcing M/S.
(I added all the spoilers to make the post shorter)

Generated 440Hz, 1 second inverted tone with 0.99 amplitude:
Spoiler (click to show/hide)

Generated a 350Hz, 1 second not inverted tone with 0.99 amplitude, and mixed it into the previous tone.
After the mix (in floating point), adapted the amplitude back to 0.99  (-0.0145 dBFS):
Spoiler (click to show/hide)

I also wanted to encode it using VBR instead of CBR, and these are the results:
Spoiler (click to show/hide)

Just to put it in context, I also compared the L/R and M/S encoding of the CBR multitone versus the original wav:
Spoiler (click to show/hide)

So, resuming:

* LAME -m j setting is intelligent enough to know when it can use M/S and when to use L/R.
* When using M/S, the encoding requires less bits. In VBR this means that the file is smaller.
* M/S encoding and L/R encoding do not produce bit-exact audio output, but the differences that have been observed in this test case are small enough to be negligible audibly speaking.
* The differences do not clearly favour either M/S nor L/R when compared to wav.
* Also, it is not clear enough from this test what could happen if using only M/S. Probably it will require a legit wide stereo stream rather than a fake 180º fake surround test.

As an additional test, I encoded one second of a synthetized track that has some aliasing up to 48Khz, and not much stereo separation with the three methods (Track sampled at 96Khz, resampled for LAME to 44Khz).
Spoiler (click to show/hide)


Re: Mp3 setting, command: -q

Reply #18
I was asking about the -q command... and here, i have been trying to understand how it could be set between -q 0 and -q 9

I can see that we are mixing a lot of important things and the discuss of mj or ms it would need another post, apart... I had read -mj (joint stereo) is usefull at low bitrates and it does not matter with high bitrates.

I always use theses comand lines: (-m s -V 4 -q 9 -lowpass 20.5) - 320 kbps @ 44.1 KHz - CBR

Re: Mp3 setting, command: -q

Reply #19
You can't use -V 4 which is VBR and then say it's 320kbps CBR? Or am I missing something? Not sure why you need to alter the lowpass either.

Re: Mp3 setting, command: -q

Reply #20
Just use -V for VBR or -b for CBR, with your desired quality level or fixed bitrate.

LAME is so well-tuned at this point that the default options really are the best options. The encoder will choose the right settings, just trust it.

Re: Mp3 setting, command: -q

Reply #21
Mid-side isn't always the best choice for all frames. It's actually more complex to encode if the stereo information is quite difficult or highly complex. Joint-stereo mode decides which mode to use on a frame-by-frame basis, depending on the complexity of the information in the source audio.

Re: Mp3 setting, command: -q

Reply #22
You can't use -V 4 which is VBR and then say it's 320kbps CBR? Or am I missing something? Not sure why you need to alter the lowpass either.

I don´t use -V4 (CBR), Lame encoder do it, itself, by default. I only set -q parameter, no more.

I never understood why Lame Encoder use -V4 (by default) when i want to set CBR. I have never used VBR setting. In other words if u use CBR the -V4 will also be there.

The Lowpass Filter is necessary to reduce all of high frecuencies... if it don´t the sound is too bright, sharp, crissp and with the known  horrible "metal voices".

Re: Mp3 setting, command: -q

Reply #23
I never understood why Lame Encoder use -V4 (by default) when i want to set CBR.
It doesn't. It's just a default value for VBR quality, but LAME doesn't use it in CBR mode.

Re: Mp3 setting, command: -q

Reply #24
The Lowpass Filter is necessary to reduce all of high frecuencies... if it don´t the sound is too bright, sharp, crissp and with the known  horrible "metal voices".
You are probably thinking of encoders that use SBR. Lame doesn't do that.

On the other hand, I don't have a problem with filtering out frequencies that you personally can't hear, to reduce file size.