Lame Installation
From Audacity Wiki
| Because of patent considerations, Audacity cannot ship with a built-in encoder to export MP3 files, but is able to use the third-party LAME encoder. This page explains how to download and install the correct LAME encoder for your system, and outlines the legal issues surrounding LAME encoding patents.
|
Contents
|
[edit] Legal issues
While the LAME source code is free, the encoding technology that ready-compiled LAME binaries use is patented. The patents are held by Fraunhofer and administered by Thomson. Patenting raises a theoretical possibility that in some countries a user might need to pay a licence fee to legally encode MP3s. This might vary according to the purpose of the encoding and whether the software being used is licensed.
There is no definitive list of countries where the patents unambiguously hold sway. However they are generally assumed to be enforceable in USA, Canada, the EEC and Japan. This means that in these countries (in theory), software that encodes MP3s must be licensed by the patent holders, and that anyone encoding MP3s with unlicensed encoders may also be infringing patents.
The best advice that can be given is that the user makes their own decision, based on their conscience, the country they are in, and taking into account the following:
- The patent holders have tended to enforce licence fees against commercial rather than free MP3 encoders
- Thomson themselves have said that no license is needed by individuals creating music libraries of MP3 files for personal use (interpretations vary whether that sanctions using unlicensed encoders, free or otherwise)
- MP3 patents will expire worldwide between 2010 and 2012
[edit] Windows Instructions
New or inexperienced users are recommended to follow the easy steps in the Simple Installation section and skip the "Advanced options for MP3 encoding" section that follows "Simple Installation".
|
[edit] Simple Installation
[edit] For 1.3.3 and later users
First, if you are using Audacity Beta 1.3.3 or later, try exporting an MP3 straight away! 1.3.3 or later on Windows will look automatically in your system folders for the LAME encoder. If you already have it, you can export an MP3 by clicking File > Export, then in the Export File dialogue, choose MP3 Files in the Save as type dropdown, and click Save. After completing the Metadata Editor for your ID3 tags (just click OK if you don't want to change the tags), you should see the progress bar for the MP3 export. Otherwise, you will see the "Locate Lame" dialogue. If that occurs, press "Cancel" and proceed as per the following "All users" section.
[edit] All users
- Download an unzipped copy of the required lame_enc.dll here
Left-click this link, do not right-click - Do not open this file, but save it to your computer. As you will be using this .dll file directly for encoding it is recommended to save it into your Audacity installation folder. This is normally at C:\Program Files\Audacity. Once lame_enc.dll is saved to your computer:
- Launch Audacity, click Edit > Preferences then the File Formats tab. Note: In Audacity 1.2.x, it may be necessary to click the left-pointing arrow top right of the window to reveal the tab. In Audacity 1.3.4 this tab is called Audio Files; in 1.3.5 - 1.3.7 Import / Export; in 1.3.8 or later Libraries.
- Look for the MP3 Export section.
- Click on the "Find Library" or "Locate..." button
- In Audacity 1.2.6 this will ask if you want to locate the LAME encoder. Click "Yes". In Audacity 1.3.3 or later, click the "Browse" button
- In the dialogue box, go to the folder where you put lame_enc.dll earlier, and select it.
- Click Open, then OK.
In the same "MP3 Export Setup" section, you can then in Audacity 1.2.6 set the bit rate of the exported MP3 by clicking on the downward pointing arrow in the "Bit Rate" dropdown.
In 1.3.3 or later, click File > Export, then choose MP3 in the "Save as type" dropdown and click the "Options" button to choose bit rate in the "Quality" dropdown. The default bit rate is 128 kbps in both versions of Audacity. A higher bit rate gives you higher quality at the expense of a larger filesize, and vice-versa. A 128 kbps bit rate takes up about 1 MB of space per minute. The "Options" button also gives access to more advanced MP3 encoding options as follows:
- Bit Rate Mode (Variable, Average, Constant or use a Preset)
- Encoding Speed (with other than constant bit rate encoding)
- Channel mode (currently Stereo or Joint Stereo ).
Constant bit rate with stereo channel mode is always used by Audacity 1.2.5/6. Variable bit rate tends in most genres to give higher quality for the same bit rate.
Additional encoding options such as higher quality algorithms are available by choosing "external program" in the "Save as type" dropdown, then specifying the relevant commands to be passed to your MP3 encoder (such as LAME) in the dialogue box.
[edit] Advanced options for MP3 encoding
Currently, using lame_enc.dll in Audacity 1.2.6 doesn't permit encoding MP3s with more advanced options such as variable bit rate (VBR), higher quality (slower) algorithms or Joint Stereo .
If these advanced options might be useful to you, you can export as a WAV file from Audacity and use LAME.exe at the command line (or in a third party program that provides an interface for it,) or use other programs that use different MP3 encoders. Alternatively the 1.3.3 or later versions of Audacity now provide advanced encoding options - see below.
[edit] Audacity 1.2.6 with LAME at the command line
If you want to use Audacity 1.2.6 with LAME.exe at the command line, download and unzip this LAME package . As well as lame_enc.dll for use in Audacity, it includes LAME.exe and the LAME documentation. To use LAME.exe, it should be run separately from Audacity (for example at the command line) on uncompressed WAV or AIFF audio files exported from your Audacity Project. To run LAME at the command line, open a command prompt from the folder location you unzipped it to, in the syntax:
- lame [options] <inputfile> [outputfile].
Online documentation for LAME is here . Vista can open a command prompt at any folder location by right-clicking over the folder. Methods for adding an easy command prompt shortcut to pre-Vista systems are listed here .
You can also drop your .WAV or .AIFF onto LAME.exe and the MP3 will be encoded at default values.
[edit] Audacity 1.2.6 with other programs
You can use LAME.exe in an interface with menus and buttons in RazorLame . This program has almost all the options offered by LAME.exe in a compact standalone interface. You'll need an unzipped copy of LAME.exe to be present in the RazorLame installation folder.
Many of the LAME encoding options are also available in a self-contained program called CD-EX . This does not need LAME.exe to be present on the computer. CD-EX is also a fine tool for extracting audio from CDs.
You can also use the Windows version of iTunes to encode to MP3 using its own proprietary MP3 encoder.
[edit] Audacity 1.3.3 and later
From 1.3.3 onwards, the advanced encoding options are accessible in the "Options" button when you export as MP3, as described above. The new 1.3.3 export options are for:
- Bit Rate Mode (Variable, Average, Constant or use a Preset)
- Encoding Speed (with other than constant bit rate encoding)
- Channel mode (currently Stereo or Joint Stereo) .
Constant bit rate with stereo channel mode is always used by Audacity 1.2.5/6. Variable bit rate (VBR) tends in most genres to give higher quality for the same bit rate.
Additional encoding options (such as those allowing the use of higher quality algorithms or a wider range of bit rates in VBR MP3s) are available by choosing "external program" in the "Save as type" dropdown when you export as MP3. In the dialogue, enter the required commands to be passed to your MP3 encoder such as LAME.exe. It's recommended to place the encoder in the Audacity installation folder. Some suggested commands giving high quality, high efficiency encoding for larger or smaller file sizes can be found here . For example, the highest quality (largest file size) setting recommended on that page would be entered thus in the Audacity Command Line Export dialog:
lame -V1 --vbr-new -b112 --lowpass 21 -q0 - "%f"
[edit] Mac Instructions
[edit] Downloading and installing
Left-click the below links, do not control-click
OS 9
Download: LameLib-Carbon-3.91.sit
OS X
For Audacity 1.2.5 for Intel Macs
Download: Lame Library v3.98.2 for Audacity.dmg
Note: this requires OS X 10.4 or later. For OS X 10.2 or 10.3, download libmp3lame-osx-universal-3.97.zip
For Audacity 1.2.6 for Power PCs
Download: LameLib-Carbon-3.91.sit
For Audacity 1.3.3 and later (Beta) (Universal Binary for Intel Macs and Power PCs)
Download: Lame Library v3.98.2 for Audacity.dmg
Note: this requires OS X 10.4 or later. For OS X 10.3, download libmp3lame-osx-universal-3.97.zip
FOR INTEL MAC USERS: If you have an Intel Mac, you should run either the Intel version of Audacity (1.2.5), or the latest Beta Universal Binary. You can run Audacity 1.2.6 for Power PCs on an Intel Mac but it is likely to run slower and is not supported. If you run 1.2.6 for Power PCs on an Intel Mac,
you must use LameLib.
|
Long or accented folder names: LAME may not work if stored in a folder with a long name or accented characters unless you are running a 1.3 Beta version of Audacity.
|
Next, go to the instructions for LameLib-Carbon-3.91.sit, Lame Library v3.98.2 for Audacity.dmg or libmp3lame-osx-universal-3.97.zip.
[edit] LameLib-Carbon-3.91.sit
- When you have finished downloading, extract the files with Stuffit or similar (this may happen automatically)
- Save the file called "LameLib" anywhere on your computer
- Launch Audacity, click Audacity > Preferences then the File Formats tab Note: it may be necessary to click the left-pointing arrow top right of the window to reveal the tab
- Look for the MP3 Export section
- Click the "Find Library" button
- This will ask if you want to locate the LAME encoder; click "Yes"
- In the dialogue box, go to the folder where you put the unstuffed "LameLib" file earlier, and select it.
- Click Open, then OK
Extra help with expanding .sit files:
Try Stuffit. It has several ways to expand a compressed file:
Alternative expanders for sit: |
[edit] Lame Library v3.98.2 for Audacity.dmg
- When you have finished downloading, double-click the .dmg to mount it, then go to the Finder (in Safari, "Lame Library v3.98.2 for Audacity.pkg" will be extracted automatically after downloading).
- Double-click "Lame Library v3.98.2 for Audacity.pkg". This will install the LAME binary "libmp3lame.dylib" in /usr/local/lib/audacity
- If Audacity asks where the MP3 encoding library is when you export as MP3:
- Click Audacity > Preferences then the File Formats tab Note: in Audacity 1.2, it may be necessary to click the left-pointing arrow top right of the window to reveal the tab. In Audacity 1.3.4 this tab is called Audio Files; in 1.3.5 - 1.3.7 Import / Export; in 1.3.8 or later Libraries.
- Look for the MP3 Export section
- Click the "Find Library" button
- In Audacity 1.2, this will ask if you want to locate the LAME encoder; click "Yes" (in Audacity 1.3, click "Browse")
- In the dialogue box, navigate to /usr/local/lib/audacity, and select "libmp3lame.dylib"
- Click Open, then OK
[edit] libmp3lame-osx-universal-3.97.zip
- When you have finished downloading, use an expander such as Stuffit or Springy to extract the files
- Save the file "libmp3lame.dylib" anywhere on your computer - it's located at the bottom of the "package" folder at libmp3lame-osx-universal-3.97/package/usr/local/lib
- Click Audacity > Preferences then the File Formats tab Note: in Audacity 1.2, it may be necessary to click the left-pointing arrow top right of the window to reveal the tab
- Look for the MP3 Export section
- Click the "Find Library" button
- In Audacity 1.2, this will ask if you want to locate the LAME encoder; click "Yes" (in Audacity 1.3, click "Browse")
- In the dialogue box, navigate to the folder where you put the unstuffed "libmp3lame.dylib" file earlier, and select it.
- Click Open, then OK
[edit] Setting bit rate and other options
Audacity 1.2.5/6: In the "MP3 Export Setup" section, set the bit rate of the exported MP3 by clicking on the downward pointing arrow in the "Bit Rate" dropdown.
Audacity 1.3.3 or later: Click File > Export, then choose MP3 in the "Save as type" dropdown and click the "Options" button to choose bit rate in the "Quality" dropdown. The default bit rate is 128 kbps in both versions of Audacity. A higher bit rate gives you higher quality at the expense of a larger filesize, and vice-versa. A 128 kbps bit rate takes up about 1 MB of space per minute. The "Options" button also gives access to more advanced MP3 encoding options as follows:
- Bit Rate Mode (Variable, Average, Constant or use a Preset)
- Encoding Speed (with other than constant bit rate encoding)
- Channel mode (currently Stereo or Joint Stereo
Constant bit rate with stereo channel mode is always used by Audacity 1.2.5/6. Variable bit rate tends in most genres to give higher quality for the same bit rate.
Additional encoding options such as higher quality algorithms are available by choosing "external program" in the "Save as type" dropdown, then specifying the relevant commands to be passed to your MP3 encoder (such as LAME) in the dialogue box.
[edit] Previous Intel Mac naming issue with Universal Binary
An early version of http://spaghetticode.org/lame/libmp3lame-osx-universal-3.97.zip mistakenly named the included MP3 encoding binary as libmp3lame.so instead of the libmp3lame.dylib which Audacity asks for. If you have this problem, please download the latest version.
[edit] Assertion error with LAME on Power PCs
Users on Power PCs may see an "assertion error" when exporting MP3s from Audacity. This is due to a bug in the LameLib binary that Audacity uses. This binary is v3.91 and outdated, but unfortunately is the only carbonised version that is currently available. You could try to export again, setting the Project Rate bottom left of the Audacity window to 44100 Hz. If this does not help, there are two alternatives:
- Download the latest Beta version of Audacity. This needs a later version of LAME, downloadable here. The latest Beta is an unfinished version of Audacity with advanced features, and requires OS X 10.4 or later. Users on OS X 10.3 can use the legacy 1.3.3 Beta together with libmp3lame-osx-universal-3.97.zip.
- Export as AIFF or WAV from Audacity and convert the file to MP3 in iTunes. See the following section.
[edit] Alternative MP3 encoding with iTunes
Export as WAV or AIFF from Audacity, drag the file into iTunes, and convert it to MP3 in ITunes 8 as follows:
- Click iTunes > Preferences
- Click on the leftmost "General" tab
- Click the Import Settings button half way down on the right
- In the "Import Using" dropdown, choose "MP3 Encoder"
- Click OK and OK
- Control-click over the file you want to convert > "Create MP3 version"
If you have iTunes 7, the setting to change is on the small "Importing" tab inside the "Advanced" tab.
[edit] Advanced MP3 encoding with LAME in iTunes
Although iTunes uses its own MP3 encoder, not LAME, you can run the LAME MP3 encoder inside iTunes with this plugin. Encoding to MP3 in iTunes using this LAME plugin will also allow you to use variable bit rate, joint stereo and other encoding options not currently available in the stable release of Audacity.
[edit] GNU/Linux/Unix instructions
[edit] Obtaining LAME
Most Linux distributions have some sort of package manager that fetches software packages from the Internet in .deb or .rpm format, and installs them for you. Open that package manager, search for LAME, and install it if it is not already installed. There are detailed instructions below for installing LAME by using the Synaptic package manager on Ubuntu or Debian systems.
[edit] Obtaining LAME using Synaptic
These are detailed steps for Ubuntu 9.04 Jaunty, but should be the same for all other Debian-based distributions of Linux.
- Open the “Synaptic” software-package manager.
- In GNOME (the default desktop environment for Ubuntu and many other systems), you can find it by clicking on the “System” menu at the top of the screen, and then choosing “Administration”.
- In KDE (the desktop environment for Kubuntu and many other systems), there will be a similar menu accessible from the bottom-left of the screen.
- In all desktop environments, you can open up a command-line terminal and type “gksu synaptic” or “sudo synaptic”.
- Enter your Ubuntu user password when asked for it.
- In the Synaptic window, choose “Settings”, then “Repositories”.
- In the "Ubuntu Software" tab, check the box for Software restricted by legal or copyright issues (“multiverse”), and then the Close button
- Back in the main Synaptic Window, type “lame” in the "Quick search" box
- The search results will show the packages “lame” and “libmp3lame0” at the top of the list. Mark both for installation (by double-clicking).
- Click the "Apply" button, and on “OK” to any warnings that come up.
- The LAME software will automatically download and install. Close the Synaptic window when it has finished.
[edit] Obtaining LAME using APT on the command line
Behind the scenes, Synaptic uses a program called APT. You can directly use APT to install LAME. First, open up a program such as xterm, GNOME-Terminal or Konsole, that gives you access to the command line.
Assuming that LAME is available in one of the repositories listed in /etc/apt/sources.list, you can install LAME with the following command:
sudo apt-get install lame libmp3lame0
You will be asked for your user password. LAME will then download and install.
Some Linux systems do not use sudo. In that case, enter these three commands:
su apt-get install lame libmp3lame0 exit
You will be asked for your root password.
[edit] LAME from source
If there isn't a LAME package for your distribution, go to the LAME Project home page and download the latest source code. Compile it as a shared object, and when Audacity prompts you for it, it will be at /usr/local/lib/libmp3lame.so.
This is for advanced users. Newer users are advised to look for a LAME package for their distribution.
[edit] Setting Audacity up to use LAME
- Open Audacity and in the Edit > Preferences window click “File Formats” (it may be called “Audio Files", “Import / Export” or "Libraries" in Beta versions of Audacity).
- In the “MP3 Export Setup”, click the “Find Library” button and then “Yes” when it asks to search for the libmp3lame.so (shared object) file.
- The file name should have a dot and a zero on the end: e.g. /usr/lib/libmp3lame.so.0 *
- Click “OK” to any warnings, and close the Preferences window.
- When you eventually export a file as MP3, click on “Options” in the export dialogue, in order to choose what bitrate (MP3 quality) you want.
* in older versions of Audacity, there had to be no “.0” on the end, and users actually had to rename the file to make it conform to this expectation.
[edit] Using LAME without Audacity
There is more to LAME than just a plug-in for Audacity. You can also just use it on the command line to encode files.
Open up a terminal, and use the cd command to navigate to a directory containing a .wav audio file. Try the following command:
lame *.wav
Replace “*” with the name of the file, or just leave it as “*” if you want to convert all .wav files in that directory.
For more help with this, type “lame --help” or “man lame”. This is also a way of checking whether lame is installed on your machine.
[edit] Troubleshooting MP3 export problems
[edit] Crash or excessive processing time on export
If Audacity crashes or hangs when exporting MP3s, or the export takes a long time to process, the usual reason is that your chosen Project Rate (the sample rate bottom left of the Audacity screen) is very different from the sample rate of the audio track on the screen (as shown in Hz on the Track Panel above the mute/solo buttons). As a result, resampling has to be done while exporting, which can create problems on long tracks. Try resampling the track to your chosen Project Rate before exporting as MP3. To do this, select all the track by clicking in the Track Panel, then Project > Quick Mix in 1.2.x or Tracks > Mix and Render in 1.3.x versions. If there is any silence added to the end of the track as a result of the resampling, you can select and delete it. Now when you export the MP3, the process should go smoothly and quickly. If it doesn't, there could be a number of reasons, e.g. if you have a virus scanner set to scan all created files, this will slow the process of writing the exported file considerably. The higher the bit rate you export at, the larger the file will be, so giving a greater time penalty if you enable virus scanning.
[edit] Exported MP3 invalid / will not play
Sometimes the exported MP3 may be invalid and only a few bytes in size. As a result, it will not play and give an error. This will happen in Audacity 1.3.2 and earlier, if a Project Rate is set (bottom left of the Audacity window) that is incompatible with the bit rate of the exported MP3. In 1.3.3 and later, an error dialogue prevents export at an incompatible sample rate.
To change bit rate in 1.3.2 and earlier, go to the File Formats tab of Preferences and look for "MP3 Export Setup". The safest solution is to always set your Project Rate to 44100 Hz. Make a rule to check this before you export, because importing a file of some other sample rate may change the Project Rate to that rate. In the current Audacity 1.2.5 (Mac Intel) and 1.2.6, 44100 Hz will always be compatible with any chosen bit rate. If exporting at 16 or 24 kbps in pre-1.2.5 versions of Audacity, it's best to choose 16000 Hz sample rate, as 44100 Hz exports will fail.
Note: in current Audacity versions, LAME will automatically downsample from 44100 Hz to a lower sample rate at 56 kbps or lower, because low bit rates may give poor quality with higher sample rates. If especially desired, any valid sample rate/bit rate combination can be enforced by using the command line exporter in the current Beta version of Audacity (choose "external program" in "Save as type" in the Export File dialogue). Or export as WAV from Audacity, then use LAME.exe at the command line to convert to MP3.
HINT: If you want to choose specific sample rate/bit rate combinations, the following shows those permitted in the MP3 specification, and which will properly export from Audacity (with or without resampling):
MPEG-1 layer III sample frequencies (kHz): 32 48 44.1:
bit rates (kbps): 32 40 48 56 64 80 96 112 128 160 192 224 256 320
MPEG-2 layer III sample frequencies (kHz): 16 24 22.05:
bit rates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160
MPEG-2.5 layer III sample frequencies (kHz): 8 12 11.025:
bit rates (kbps): 8 16 24 32 40 48 56 64 80 96 112 128 144 160
[edit] Exported MP3 plays too fast
If the MP3 plays at the wrong speed (usually too fast), then the sample rate you exported it at is unsuitable for your player application. Once again, the safe solution is to always set your Project Rate to 44100 Hz. This was a known problem with Adobe Flash Player until some way into version 9: for the file to play properly, the sample rate had to be 11025 Hz or a multiple thereof, such as 22050 Hz or 44100 Hz. This is fixed in the current Adobe Flash Player.
[edit] Exported MP3 has low volume or no sound
If you can see your exported MP3 is playing because the timer on the media player is moving, but it has no sound, make sure the sound device is not muted (in the player or in the system control panel), and make sure the correct playback device is being used (in the player preferences or in the system control panel). If this is not the problem, go back to Audacity and make sure the -....+ gain slider on the Track Panel (where the mute/solo buttons are) is set centrally at "Gain: 0 db". If this slider is over to left, it will reduce or kill the volume in the exported MP3.
[edit] ID3 Tags
Make sure when you use the "Edit ID3 Tags" dialogue that you complete this by pressing OK, not escaping or cancelling it. In current versions of Audacity the Edit ID3 Tags dialogue does not come up automatically when you make a subsequent MP3 export in the same session, but you can always set the ID3 tags before exporting an individual MP3 file at Project > Edit ID3 tags in Audacity 1.2.6 or File > Open Metadata Editor in Audacity 1.3.x.
When using File > Export Multiple, the ID3 tag editor comes up once for the batch of files which you are multiple exporting. The "Title" and "Track Number" tags will be automatically determined by the name you give to each file and the order of the exported tracks, but you can type in data for the other tags which will then apply to all the exported files in that batch.
HINT: export of ID3v2 tags is broken in 1.3.0 to 1.3.2 versions of Audacity. ID3v2 tags will be exported but only readable by iTunes. To fix this, upgrade to the current Audacity Beta .
[edit] Exported MP3 larger than imported one
If you import an MP3 file into Audacity, then after export you find it is much larger than before, this is because the bit rate you exported it at (by default, Audacity exports MP3s at 128 kbps), is higher than the bit rate of the file before you imported it. If you need the exported MP3 to be the same size as before:
- Find out the bit rate of the imported file by opening it in Windows Media Player and clicking File > Properties, or in iTunes, right-click or control-click over the file and click Get Info.
- Go to Audacity Preferences > File Formats tab: "MP3 Export Setup", click the downward pointing arrow in the Bit Rate dropdown and choose the original bit rate of your imported MP3. Note: in Audacity 1.3.4 this tab is called Audio Files and in 1.3.5 or later it is called Import / Export.
Note that reducing the export bit rate will reduce the quality of the exported file below that of the file you exported at a higher bit rate. In fact, whatever bit rate you export at, importing an MP3 file and re-exporting it as an MP3 will always lead to a further loss of quality compared to the imported MP3. Re-encoding the file as an MP3 when you export it cannot be avoided in Audacity, because it always decompresses the MP3 upon import. This is essential to maintain the quality of the file when applying complex edits such as equalisation.
But if you only want to do simple cut, copy, paste, fade and volume edits to your MP3s, you can do so without audio losses in other tools that can edit the MP3s directly without decompressing and re-encoding them. Two examples are MP3DirectCut for Windows and Linux (under Wine) and Audion for OS X.
MP3s of the same bit rate, sample rate and channel mode can also be joined non-destructively with these tools without the need for lossy re-encoding.
