Unknown encoder 'libmp3lame' in Ubuntu 14.04

I'm running Ubuntu 14.04.1 LTS. The question looks like this Unknown encoder 'libmp3lame', but I followed everything there and installed every package they mentioned but still I am getting the error.

I am trying to convert FLAC to MP3 using ffmpeg, with below command:

ffmpeg -i hang_drum.flac -acodec libmp3lame destination_path.mp3

Error:

ffmpeg version 2.3.3 Copyright (c) 2000-2014 the FFmpeg developers
 built on Sep  5 2014 17:58:33 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: 
  libavutil      52. 92.100 / 52. 92.100
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 48.100 / 55. 48.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.100 /  4. 11.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
Input #0, flac, from 'hang_drum.flac':
  Metadata:
    TSS             : Logic 10.0.6
    ENCODER         : Lavf55.44.100
  Duration: 00:02:36.06, start: 0.000000, bitrate: 627 kb/s
    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16

I tried:

  • sudo apt-get install ffmpeg libavcodec-extra-53
  • sudo apt-get install ffmpeg libavcodec-extra-54
  • sudo apt-get install libmp3lame0
  • sudo apt-get install libav-tools:i386
  • sudo apt-get install ffmpeg libav-tools

After running these, I'm still getting the same error libmp3lame. What am I missing here?


Ubuntu does not officially bundle ffmpeg after ditching it in favor of the Libav fork. There is a PPA that is quite outdated, so it should not be used unless you're keen on running an old version of ffmpeg.

I honestly have to confess that I don't know why it won't work for your specific case—or how you got an ffmpeg running in the first place, since Ubuntu does not bundle it officially.

Here are two solutions that should always work though:

Use a static build

A quick solution would be to simply download a recent static build (scroll down where it says Linux Static Builds). These all have libmp3lame bundled. Extract that build to some location, and copy ffmpeg to a directory in your PATH, e.g.:

cd ~/Downloads
tar xvf ffmpeg-*.tar.xz
cd !$
sudo mkdir -p /usr/local/bin
sudo cp ./ffmpeg ./ffprobe /usr/local/bin/
sudo chmod ugo+x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe

Also make sure that /usr/local/bin is in your shell PATH.

Compile from source

This will also give you the latest version with all extras you want. Follow the always up-to-date guide on the FFmpeg wiki. It'll take a bit longer, but gives you more configuration options, and access to other encoders, such as libfdk_aac, which cannot be statically bundled due to licensing reasons.


The problem

It appears that you compiled ffmpeg, but you omitted the configure option --enable-libmp3lame which is required to be able to encode MP3 audio (there is also --enable-libshine, but that's a fixed-point MP3 encoder that most users won't need).

Additionally you'll need the libmp3lame-dev package as a dependency before compiling. Currently this needs to provide LAME ≥ 3.98.3, so if your package is too old then you can also compile LAME instead.

How to fix

You have 3 main options if you want to use FFmpeg:

Compile

As mentioned above you will need the LAME dependencies and use the --enable-libmp3lame configure option. See the Ubuntu FFmpeg Compile Guide for step-by-step instructions.

Download

You can simply download, extract, and run a static build of ffmpeg. It has MP3 encoding enabled.

PPA

Ubuntu 14.04 users can utilize mc3man's Ubuntu Multimedia for Trusty. It also supports MP3 encoding.