Lame Installation

From Audacity Wiki
Jump to: navigation, search
Peter 2May14: This page is a potential candidate for deprecation, the material is, or should be, handled more than adequately in the Manual. There may be useful additional information here that could usefully be transferred to the Manual. We may wish to consider leaving it here.
  • Gale 17Jun14: This page can be deleted and a redirect to MP3 left behind when material from it has been transferred to MP3.
  • Peter 17Jun14: But note there are links to this page from the Manual>FAQ here for MAC and here for Linux.
  • Peter 02Oct14: I decided to leave this page here for now (I removed the Ps) as it is still referenced from those two places in the Manual (which implies that the MAC and Linux info here is richer than that in the Manual) - and there are probably many references in the Forum.

    ToDo-2 Placeholder to retain focus - we may yet decide to delete this page in favor of the Manual content.

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

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)
  • Existing MP3 patents will expire worldwide between 2010 and 2012 (but not until 2017 in the USA)
  • The possibility remains at least in the USA that patents could be extended.

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".

Simple Installation

Try it

Try exporting an MP3 straight away Audacity 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.

All users

See http://manual.audacityteam.org/o/man/faq_installation_and_plug_ins.html#lame .

After installation of lame_enc.dll, 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. 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:

  1. Bit Rate Mode (Variable, Average, Constant or use a Preset)
  2. Encoding Speed (with other than constant bit rate encoding)
  3. Channel mode (currently Stereo or Joint Stereo).

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.

Advanced options for MP3 encoding

The advanced encoding options are accessible in the "Options" button when you export as MP3, as described above. The export options are for:

  1. Bit Rate Mode (Variable, Average, Constant or use a Preset)
  2. Encoding Speed (with other than constant bit rate encoding)
  3. Channel mode (currently Stereo or Joint Stereo).

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"


Mac Instructions

Downloading and installing

Left-click the below links, do not control-click

OS X 10.4 or later, Intel or PPC Mac:

Lame Library v3.98.2 for Audacity.dmg

  1. Use the current Audacity and download Lame Library v3.98.2 for Audacity.dmg
  2. 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).
  3. Double-click "Lame Library v3.98.2 for Audacity.pkg". This will install the LAME binary "libmp3lame.dylib" in /usr/local/lib/audacity
  4. If Audacity asks where the MP3 encoding library is when you export as MP3:
    1. Click Audacity > Preferences then the Libraries tab ## Look for the MP3 Export section
    2. Click the "Find Library" button
    3. Click "Browse"
    4. In the dialogue box, navigate to /usr/local/lib/audacity, and select "libmp3lame.dylib"
    5. Click Open, then OK

Lame_Library_v3.98.2_for_Audacity_on_OSX.zip

  1. Use the current Audacity and download Lame Library v3.98.2_for Audacity on OSX.zip
  2. When you have finished downloading, use an expander such as Stuffit or Springy to extract the files
  3. Save the file "libmp3lame.dylib" anywhere on your computer
  4. Click Audacity > Preferences then the File Formats tab
  5. Look for the MP3 Export section
  6. Click the "Find Library" button
  7. Click "Browse")
  8. In the dialogue box, navigate to the folder where you put the unstuffed "libmp3lame.dylib" file earlier, and select it.
  9. Click Open, then OK

Setting bit rate and other options

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:

  1. Bit Rate Mode (Variable, Average, Constant or use a Preset)
  2. Encoding Speed (with other than constant bit rate encoding)
  3. Channel mode (currently Stereo or Joint Stereo).

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.

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:

  1. Click iTunes > Preferences
  2. Click on the leftmost "General" tab
  3. Click the Import Settings button half way down on the right
  4. In the "Import Using" dropdown, choose "MP3 Encoder"
  5. Click OK and OK
  6. 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.

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 on Mac with by following the instructions half way down this page. Encoding to MP3 in iTunes using this LAME plug-in will also allow you to use variable bit rate, joint stereo and other encoding options.


GNU/Linux/Unix instructions

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.

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.

  1. 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”.
  2. Enter your Ubuntu user password when asked for it.
  3. In the Synaptic window, choose “Settings”, then “Repositories”.
  4. In the "Ubuntu Software" tab, check the box for Software restricted by legal or copyright issues (“multiverse”), and then the Close button
  5. Back in the main Synaptic Window, type “lame” in the "Quick search" box
  6. The search results will show the packages “lame” and “libmp3lame0” at the top of the list. Mark both for installation (by double-clicking).
  7. Click the "Apply" button, and on “OK” to any warnings that come up.
  8. The LAME software will automatically download and install. Close the Synaptic window when it has finished.

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.

DEBIAN Linux: LAME and "libmp3lame0"

  1. If you cannot find "libmp3lame0" in the repositories you need to add "debian-multimedia" to your "sources.list".
  2. Follow the instructions found here: http://debian-multimedia.org/ - choose a mirror if you wish.
  3. Remember: editing your sources.list requires ROOT privileges "sudo {your_text_editor} /etc/apt/sources.list" - make a backup!
  4. Once done you can use "Synaptic" or "apt-get" to install "lame" and "libmp3lame0".

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. 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.

Setting Audacity up to use LAME

  1. Open Audacity and in the Edit > Preferences window click “Libraries" (this may be called "File Formats”, "Audio Files" or "Import / Export" in legacy versions of Audacity).
  2. In the "MP3 Export Library" section, click "Locate" then "Browse" and navigate to the location of the libmp3lame.so (shared object) file
  3. The file name should have a dot and a zero on the end: e.g. /usr/lib/libmp3lame.so.0 *
  4. Click "OK" on any warnings then close the Preferences window.
  5. When you export an MP3 file, click on "Options" in the export window in order to choose what bit rate (MP3 quality) you want.

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.

Troubleshooting MP3 export problems

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 Control 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 Control Panel, then Tracks > Mix and Render. 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.

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.

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.

LAME will automatically downsample from 44 100 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 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

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.

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 Control 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.

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 File > Open Metadata Editor.

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.

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 is higher than the bit rate of the original file.

Audacity defaults to 128 kbps bit rate then remembers the last used bit rate if you change it.

If you need the exported MP3 to be the same size as before:

  1. 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. You can also use standalone programs like MediaInfo.
  2. Click File > Export, choose "MP3 Files" in the file types list, then click the Options button.

If you export a low bit rate MP3 at the same bit rate as the original you will be degrading its quality much more than if you exported it at a higher bit rate. The penalty of the higher bit rate is that the new file would be larger and that file merge tools might no longer be able to join the new MP3 to others that had the original bit rate. If you export a high bit rate MP3 at the same bit rate you are helping to minimise quality loss (but are not saving anything in file size).

All MP3 exports are lossy

Every MP3 export reduces the quality of the original file because Audacity does not edit the file directly. Instead, Audacity decompresses the MP3 upon import to lossless PCM. This does not undo the audio losses caused by the original MP3 compression, but it enables more complex edits such as equalisation and other signal filtering to be made.

Having been decompressed, the MP3 therefore has to be re-encoded as a new compressed MP3 when exporting. The lower the bit rate exported at, the more quality will be lost with that re-encoding.

If you only want to do simple cut, copy, paste, fade and volume edits to your MP3 files, you can do so without audio losses in other tools that can edit MP3 directly without decompressing and re-encoding. Examples are:

  • mp3wrap - Cross-Platform command-line only tool for joining MP3 files.

MP3 files of the same bit rate, sample rate, number of channels and stereo encoding mode can be typically be joined non-destructively with any of the above tools without the need for lossy re-encoding.

Personal tools

Donate securely by PayPal, using your credit card or PayPal account!