LAME: Difference between revisions

From Hydrogenaudio Knowledgebase
Line 41: Line 41:


==Recommended encoder settings==
==Recommended encoder settings==
This section describes the [[Hydrogenaudio]] recommended settings to be used with [[LAME]] for highest quality [[MP3]] encoding.
This section describes the [[Hydrogenaudio]] recommended settings to be used with [[LAME]] for highest quality [[MP3]] encoding. These settings require LAME 3.94 or later (the latest stable version is recommended).
 
These settings require '''LAME 3.94''' or later. '''LAME 3.97''' is the recommended version.


===Quick start (short answer)===
===Quick start (short answer)===
Line 49: Line 47:


<code><font style="color:red">-b 320</font></code>. This is the strongest setting for [[MP3]], with the lowest risk of [[artifact]]s.
<code><font style="color:red">-b 320</font></code>. This is the strongest setting for [[MP3]], with the lowest risk of [[artifact]]s.
With the exception of a few situations, quality is rarely better than the highest [[VBR]] profiles described below. However, 'archiving' music using a lossy format like [[MP3]] is never recommended &ndash; no matter how transparent the resulting files might be.
With the exception of a few situations, quality is rarely better than the highest [[VBR]] profiles described below. However, 'archiving' music using a lossy format like [[MP3]] is never recommended &ndash; no matter how transparent the resulting files might sound.
The alternative is to use [[Lossless]] formats like [[WavPack]], [[FLAC]] etc. that allow true archiving bit for bit like on original CD.
The alternative is to use [[Lossless]] formats like [[WavPack]], [[FLAC]] etc. that allow true archiving, bit for bit like on the original CD.


====High quality: <font style="color:green">HiFi, home or quiet listening</font>====
====High quality: <font style="color:green">HiFi, home or quiet listening</font>====


<code><font style="color:green">-V3 --vbr-new</font></code> (~175 kbps), <code><font style="color:green">-V2 --vbr-new</font></code> (~190 kbps), <code><font style="color:green">-V1 --vbr-new</font></code> (~210 kbps) or <code><font style="color:green">-V0 --vbr-new</font></code> (~230 kbps) are recommended.
<code><font style="color:green">-V0 --vbr-new</font></code> (~230 kbps), <code><font style="color:green">-V1 --vbr-new</font></code> (~210 kbps), <code><font style="color:green">-V2 --vbr-new</font></code> (~190 kbps) or <code><font style="color:green">-V3 --vbr-new</font></code> (~175 kbps) are recommended.
These settings will produce [[transparent]] encoding (transparent = most people cannot distinguish the [[MP3]] from the original in an [[ABX]] blind test).
These settings will normally produce [[transparent]] encoding (transparent = most people cannot distinguish the [[MP3]] from the original in an [[ABX]] blind test).
Audible differences between these presets exist, but are extremely rare.
Audible differences between these presets exist, but are rare.


====Portable: <font style="color:purple">background noise and low bitrate requirement, small sizes</font>====
====Portable: <font style="color:purple">background noise and low bitrate requirement, small sizes</font>====


<code><font style="color:purple">-V6 --vbr-new</font></code> (~115 kbps), <code><font style="color:purple">-V5 --vbr-new</font></code> (~130 kbps) or <code><font style="color:purple">-V4 --vbr-new</font></code> (~160 kbps) are recommended for this use.
<code><font style="color:purple">-V4 --vbr-new</font></code> (~160 kbps), <code><font style="color:purple">-V5 --vbr-new</font></code> (~130 kbps) or <code><font style="color:purple">-V6 --vbr-new</font></code> (~115 kbps) are recommended.
<code><font style="color:purple">-V6 --vbr-new</font></code> produces an acceptable quality, while <code><font style="color:purple">-V4--vbr-new</font></code> should be close to perceptual [[transparency]].
<code><font style="color:purple">-V6 --vbr-new</font></code> produces an "acceptable" quality, while <code><font style="color:purple">-V4--vbr-new</font></code> should be close to perceptual [[transparency]].


====Very low bitrate, small sizes: <font style="color:blue">eg. for voice, radio, [[mono]] encoding etc.</font>====
====Very low bitrate, small sizes: <font style="color:blue">eg. for voice, radio, [[mono]] encoding etc.</font>====
Line 157: Line 155:


===Remarks===
===Remarks===
* The rule of thumb when considering encoding options: at a given bitrate, [[VBR]] is higher quality than [[ABR]], which is higher quality than [[CBR]] ([[VBR]] > [[ABR]] > [[CBR]] in terms of quality). The exception to this is when you choose the highest possible [[CBR]] bitrate, which is 320 kbps (-b 320 = --alt-preset insane), but this produces very large filesizes for very little audible benefit.
* The rule of thumb when considering encoding options: at a given bitrate, [[VBR]] is higher quality than [[ABR]], which is higher quality than [[CBR]] ([[VBR]] > [[ABR]] > [[CBR]] in terms of quality). The exception to this is when you choose the highest possible [[CBR]] bitrate, which is 320 kbps (-b 320 = --alt-preset insane), but this produces the largest filesizes for doubtful audible benefit.


* All modes and settings mentioned in this topic belong to the specifications of the [[MP3]] standard, and the resulting MP3s should be playable by every [[MP3]] decoder that conforms with the standard. If your decoder or device does not play MP3s produced by LAME, blame the manufacturer or developer, and not LAME.
* All modes and settings mentioned in this topic belong to the specifications of the [[MP3]] standard, and the resulting MP3s should be playable by every [[MP3]] decoder that conforms with the standard. If your decoder or device does not play MP3s produced by LAME, blame the manufacturer or developer, not LAME.


* Avoid using alpha (a) versions of LAME. More often than not those are exclusively for testing purposes. Use them only if you want to help developers with feedback. History of [http://www.hydrogenaudio.org/forums/index.php?showtopic=28125/ Lame versions & compiles].
* Avoid using alpha (a) versions of LAME. More often than not those are exclusively for testing purposes. Use them only if you want to help developers with feedback. History of [http://www.hydrogenaudio.org/forums/index.php?showtopic=28125/ Lame versions & compiles].


* The <code>--vbr-new</code> switch enables the new [[VBR]] mode. Lame will encode much faster than the old/default [[VBR]] mode. In terms of quality, <code>--vbr-new</code> appears to be better than the old model, but reports of artifacts when using the new model do exist. Despite these possible issues, <code>--vbr-new</code> is currently recommended over the default [[VBR]] mode due to both the speed and quality increases afforded by the new algorithm.
* The <code>--vbr-new</code> switch enables the new [[VBR]] mode (no longer needed with LAME 3.98). In terms of quality, <code>--vbr-new</code> appears to be better than the old model, but reports of artifacts when using the new model do exist. Despite these possible issues, <code>--vbr-new</code> is currently recommended over the default [[VBR]] mode due to both the speed and quality increases afforded by the new algorithm.


* '''-mm''' : the sound will be encoded in '''mono'''. Eg. useful for low bitrates & when stereo is less important.
* '''-mm''' : the sound will be encoded in '''mono'''. Useful for low bitrates and/or when stereo is not important.




[[Image:lame-chart-2.png|frame|center|Here a trial to get a view, how the <font style="color:red">perceived listening quality</font> improves with settings/<font style="color:blue">averaged filesize</font>]]
[[Image:lame-chart-2.png|frame|center|Here a trial to see how the <font style="color:red">perceived listening quality</font> improves with settings/<font style="color:blue">averaged filesize</font>]]




Line 184: Line 182:


(<code>--preset cbr 320</code> is the exact same thing as <code>--alt-preset insane</code>, etc.)
(<code>--preset cbr 320</code> is the exact same thing as <code>--alt-preset insane</code>, etc.)


==Technical information==
==Technical information==

Revision as of 00:27, 23 July 2008

LAME
{{{logo}}}
LAME official logo
LAME ain't an MP3 encoder
Developer(s) The LAME project
Release information
Initial release {{{released}}}
Stable release 3.98
Preview release none
Compatibility
Operating system Windows, Mac OS/X, Linux/BSD
Additional information
Use Encoder/Decoder
License LGPL
Website LAME website
Featured article

LAME (Lame Ain't an MP3 Encoder) is the Hydrogenaudio recommended MP3 encoder. It has been developed by the open-source community since 1998, and has become the highest quality MP3 encoder for most purposes.

Some benefits of using LAME:

  • Highly optimised presets
  • Fast encoding
  • CBR, ABR and quality-optimized VBR encoding methods
  • Gapless playback with LAME-header compliant decoders
  • Supported by recommended CD rippers Exact Audio Copy and CDex
  • Highly tunable


History

LAME development began around mid-1998. Mike Cheng started it as a patch against the 8hz-MP3 encoder sources. After some quality concerns raised by others, he decided to start from scratch based on the dist10 sources. That branch (a patch against the reference sources) became LAME 2.0, and only on LAME 3.81 they got rid of all dist10 code, making LAME a completely new program-not a mere patch of an existing encoder.

The project quickly became a team effort. Mike Cheng eventually left leadership and started working on tooLAME, an MP2 encoder. Mark Taylor became leader and released version 3.0 featuring gpsycho, a new psychoacoustic model developed by him.

Nowadays LAME is considered the best MP3 encoder at mid-high bitrates and features the best VBR model among MP3 implementations, mostly thanks to the dedicated work of talented developers like Takehiro Tominaga, Naoki Shibata, Darin Morrison, Gabriel Bouvigne, Robert Hegemann, etc. And development is still going on...


Recommended encoder compiles and source code

Unless noted otherwise, the recommended LAME compile for optimal quality is always the latest stable version.

It is suggested that the compiles available here be used with the recommended encoder settings you can find below.

Download the latest LAME from these links:

Recommended encoder settings

This section describes the Hydrogenaudio recommended settings to be used with LAME for highest quality MP3 encoding. These settings require LAME 3.94 or later (the latest stable version is recommended).

Quick start (short answer)

Best quality: "archiving"

-b 320. This is the strongest setting for MP3, with the lowest risk of artifacts. With the exception of a few situations, quality is rarely better than the highest VBR profiles described below. However, 'archiving' music using a lossy format like MP3 is never recommended – no matter how transparent the resulting files might sound. The alternative is to use Lossless formats like WavPack, FLAC etc. that allow true archiving, bit for bit like on the original CD.

High quality: HiFi, home or quiet listening

-V0 --vbr-new (~230 kbps), -V1 --vbr-new (~210 kbps), -V2 --vbr-new (~190 kbps) or -V3 --vbr-new (~175 kbps) are recommended. These settings will normally produce transparent encoding (transparent = most people cannot distinguish the MP3 from the original in an ABX blind test). Audible differences between these presets exist, but are rare.

Portable: background noise and low bitrate requirement, small sizes

-V4 --vbr-new (~160 kbps), -V5 --vbr-new (~130 kbps) or -V6 --vbr-new (~115 kbps) are recommended. -V6 --vbr-new produces an "acceptable" quality, while -V4--vbr-new should be close to perceptual transparency.

Very low bitrate, small sizes: eg. for voice, radio, mono encoding etc.

For very low bitrates, up to 100kbps, ABR is most often the best solution. Use --abr <bitrate> (e.g. --abr 80).

--preset voice is only available in the command line front-end, and is there for compatibility. It is currently mapped to --abr 56 -mm, so that means that the recommendation would be to encode in mono, and use ABR.

Detailed explanation (long answer)

VBR (variable bitrate) settings

VBR: variable bitrate mode. Use variable bitrate modes when the goal is to achieve a fixed level of quality using the lowest possible bitrate.

VBR is best used to target a specific quality level, instead of a specific bitrate. The final file size of a VBR encode is less predictable than with ABR, but the quality is usually better.

Unlike other MP3 encoders which do VBR encoding based on predictions of output quality, LAME's default VBR method tests the actual output quality to ensure the desired quality level is always achieved.

Usage: -V(number) where number is 0-9, 0 being highest quality, 9 being the lowest.

Example: -V2


List of recommended settings
Switch Preset Target Kbit/s Bitrate range kbit/s
-b 320 --preset insane 320 320 CBR
-V 0 --vbr-new --preset fast extreme 245 220...260
-V 0 --preset extreme 245 220...260
-V 1 --vbr-new   225 200...250
-V 1   225 200...250
-V 2 --vbr-new --preset fast standard 190 170...210
-V 2 --preset standard 190 170...210
-V 3 --vbr-new   175 155...195
-V 3   175 155...195
-V 4 --vbr-new --preset fast medium 165 145...185
-V 4 --preset medium 165 145...185
-V 5 --vbr-new   130 110...150
-V 5   130 110...150
-V 6 --vbr-new   115 95...135
-V 6   115 95...135
-V 7 --vbr-new   100 80...120
-V 7   100 80...120
-V 8 --vbr-new   85 65...105
-V 8   85 65...105
-V 9 --vbr-new   65 45...85
-V 9   65 45...85

See also Technical details for recommended LAME settings.

If you need a predictable bitrate (in a streaming application, for example), use ABR or CBR modes, described below.

ABR (average bitrate) settings

ABR: average bitrate mode. A compromise between VBR and CBR modes, ABR encoding varies bits around a specified target bitrate.

Use ABR when you need to know the final size of the file but still want to allow the encoder some flexibility to decide which passages need more bits.

Usage: --preset <bitrate> where <bitrate> (desired averaged bitrate in kbit/s) can be any value between 8 - 320 , like eg. 9, 17, 80, 128, 133, 200 etc.

Example: --preset 200

Important: ABR setting is tuned from 320 kbit/s down to 80 kbit/s.

CBR (constant bitrate) settings

CBR: constant bitrate mode. CBR encoding is not efficient. Whereas VBR and ABR modes can supply more bits to complex music passages and save bits on simpler ones, CBR encodes every frame at the same bitrate.

CBR is only recommended for usage in streaming situations where the upper bitrate must be strictly enforced.

Usage: -b <bitrate> where <bitrate> (bitrate in kbit/s) must be chosen from the following values: 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, or 320.

Example: -b 192

Important: CBR setting is tuned from 320 kbit/s down to 80 kbit/s.

Remarks

  • The rule of thumb when considering encoding options: at a given bitrate, VBR is higher quality than ABR, which is higher quality than CBR (VBR > ABR > CBR in terms of quality). The exception to this is when you choose the highest possible CBR bitrate, which is 320 kbps (-b 320 = --alt-preset insane), but this produces the largest filesizes for doubtful audible benefit.
  • All modes and settings mentioned in this topic belong to the specifications of the MP3 standard, and the resulting MP3s should be playable by every MP3 decoder that conforms with the standard. If your decoder or device does not play MP3s produced by LAME, blame the manufacturer or developer, not LAME.
  • Avoid using alpha (a) versions of LAME. More often than not those are exclusively for testing purposes. Use them only if you want to help developers with feedback. History of Lame versions & compiles.
  • The --vbr-new switch enables the new VBR mode (no longer needed with LAME 3.98). In terms of quality, --vbr-new appears to be better than the old model, but reports of artifacts when using the new model do exist. Despite these possible issues, --vbr-new is currently recommended over the default VBR mode due to both the speed and quality increases afforded by the new algorithm.
  • -mm : the sound will be encoded in mono. Useful for low bitrates and/or when stereo is not important.


Here a trial to see how the perceived listening quality improves with settings/averaged filesize


Hey! What happened to "--alt-preset"?

The revolutionary --alt-preset system was introduced in LAME 3.90; it was replaced by the --preset flags in later versions. Starting with version 3.94, the -Vx quality system was introduced, which allows finer control over the desired bitrate; the --preset switches were made into aliases to the corresponding -V flags for the sake of backwards compatibility. There is no difference between the output you get if you use -V2 or --alt-preset standard. (Although adding --vbr-new is recommended for now, see above for details.)

More encoding options are available under the new system, such as -V1, which provides a level of quality between the old "standard" and "extreme" presets, or -V3, which is between the old "medium" and "standard" presets.

LAME 3.97 features more streamlined command line options, and it's recommended to stick to one of the values described in the text or shown in the tables above. You don't need to worry anymore about quality, settings, arcane combinations of switches, or presets.

For example, the following command lines will all produce the same output:

--alt-preset insane = --preset insane = -b 320 = --preset 320 = --preset cbr 320

(--preset cbr 320 is the exact same thing as --alt-preset insane, etc.)

Technical information

The table below contains technical details about the recommended settings.


Technical details of the recommended settings
Switch Preset Target Kbps Y Switch -b Lowpass Resample
-V 0 --preset extreme ~240 128 19383 Hz - 19916 Hz
-V 0 --vbr-new --preset fast extreme ~240 19383 Hz - 19916 Hz
-V 1 ~210 128 18671 Hz - 19205 Hz
-V 1 --vbr-new ~210 18671 Hz - 19205 Hz
-V 2 --preset standard ~190 128 18671 Hz - 19205 Hz
-V 2 --vbr-new --preset fast standard ~190 18671 Hz - 19205 Hz
-V 3 ~175 Y 17960 Hz - 18494 Hz
-V 3 --vbr-new ~175 Y 17960 Hz - 18494 Hz
-V 4 --preset medium ~165 Y 17960 Hz - 18494 Hz
-V 4 --vbr-new --preset fast medium ~165 Y 17960 Hz - 18494 Hz
-V 5 ~130 Y 16538 Hz - 17071 Hz
-V 5 --vbr-new ~130 Y 16538 Hz - 17071 Hz
-V 6 ~115 Y 15826 Hz - 16360 Hz
-V 6 --vbr-new ~115 Y 15826 Hz - 16360 Hz
-V 7 ~100 Y 14581 Hz - 14968 Hz 32000 Hz
-V 7 --vbr-new ~100 Y 14581 Hz - 14968 Hz 32000 Hz
-V 8 ~85 Y 12516 Hz - 12903 Hz 32000 Hz
-V 8 --vbr-new ~85 Y 12516 Hz - 12903 Hz 32000 Hz
-V 9 ~65 Y 9774 Hz - 10065 Hz 24000 Hz
-V 9 --vbr-new ~65 Y 9774 Hz - 10065 Hz 24000 Hz


See also


Notes and references

People who took part in suggesting the different settings:

Dibrom, r3mix, ff123, Hans Heijden, kjempen, Benjamin Lebsanft, GeSomeone, Wombat & GuruBoolez for his immense testing.

Creation of the alt preset system and related special code level quality enhancements:

Dibrom, with technical assistance from Robert Hegemann and Naoki Shibata, Gabriel and extensive tuning help and quality verification via listening tests from JohnV and also initial help (--dm-preset era) from Hans Heijden, ff123, Wombat, and others. Test clips, bitrate information, and further listening tests provided by TheBashar, zbutsam, Pio2001, BadDuDeX, r3mix, h, TarX, Hans Heijden, ff123, Wombat, Filburt, Volcano, Garf, MrDrew, TrNSZ, nyaochi, Amadeus93, in no particular order, and many, many others we (Dibrom, user) probably forgot to mention.

Idea (also exposing the need for a unified preset system), Original post and list of original settings collected by: user

Layout and additional work by: dev0, CiTay, SNYder, Dibrom.

And finally...

Thank you ALL in the community for making it what it is, providing interest and discussion and helping to work towards the most concise, well tuned, and most thought out MP3 quality "paradigm" seen yet! -- Dibrom


Further reading


External links