Encoding mp3 audio with ffmpeg on Ubuntu Hardy

If you already have ffmpeg installed (without mp3 support), then firstly uninstall it.

MP3 support isn’t included with ffmpeg in the default Ubuntu repositories so to get it you have to enable the Medibuntu repos (assuming this is legal in your area).

sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O - | sudo apt-key add - && sudo apt-get update

Then you can install ffmpeg and the libmp3lame codec (part of the libavcodec package)

sudo apt-get install ffmpeg
sudo apt-get install libavcodec1d

You can verify the dependencies of ffmpeg with ldd

paul@paul:~/Videos$ ldd /usr/bin/ffmpeg 
	linux-gate.so.1 =>  (0xb7f07000)
	libavformat.so.1d => /usr/lib/libavformat.so.1d (0xb7e72000)
	libavcodec.so.1d => /usr/lib/libavcodec.so.1d (0xb7997000)
	libavutil.so.1d => /usr/lib/libavutil.so.1d (0xb798c000)
	libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7967000)
	libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb794f000)
	libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7800000)
	libz.so.1 => /usr/lib/libz.so.1 (0xb77eb000)
	libogg.so.0 => /usr/lib/libogg.so.0 (0xb77e6000)
	libdc1394_control.so.13 => /usr/lib/libdc1394_control.so.13 (0xb77d6000)
	libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb77d2000)
	liba52-0.7.4.so => /usr/lib/liba52-0.7.4.so (0xb77c7000)
	libgsm.so.1 => /usr/lib/libgsm.so.1 (0xb77ba000)
	libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0xb7725000)
	libtheora.so.0 => /usr/lib/libtheora.so.0 (0xb76db000)
	libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0xb76b3000)
	libvorbisenc.so.2 => /usr/lib/libvorbisenc.so.2 (0xb75ba000)
	libxvidcore.so.4 => /usr/lib/libxvidcore.so.4 (0xb74a2000)
	libx264.so.57 => /usr/lib/libx264.so.57 (0xb7417000)
	libfaac.so.0 => /usr/lib/libfaac.so.0 (0xb7406000)
	/lib/ld-linux.so.2 (0xb7f08000)
	libraw1394.so.8 => /usr/lib/libraw1394.so.8 (0xb73ff000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0xb7318000)
	libxcb-xlib.so.0 => /usr/lib/libxcb-xlib.so.0 (0xb7316000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb72fe000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0xb72fa000)
	libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb72f5000)

It should then let you encode videos with mp3 audio…

ffmpeg -i jonathan-davis-news24-2008-01-22.avi -f flv -s 400s220 -acodec mp3 -ar 44100 jd.flv

9 thoughts on “Encoding mp3 audio with ffmpeg on Ubuntu Hardy”

  1. libavcodec1d was what i was missing – installing it allowed me to output mp3 audio on transcoded videos :) thankyou for this. most of the other how-tos involve recompiling ffmpeg and that seemed like total overkill.

  2. ubuntu 8.04 NOT WORK !!!

    Output #0, flv, to ‘3_0.flv’:
    Stream #0.0: Video: flv, yuv420p, 180×144, q=2-31, 200 kb/s, 25.00 fps(c)
    Stream #0.1: Audio: 0x0000, 44100 Hz, stereo, 64 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
    Unsupported codec for output stream #0.1

  3. It works in Ubuntu 8.04, but you have to force-install the Medibuntu versions of both ffmpeg and libavcodec1d – I used synaptic to achieve this.

  4. You have to make sure you install the medibuntu version of ffmpeg and libavcodec1d, or you won’t get the support for mp3 encoding.

    ldd /usr/bin/ffmpeg will show you the dependencies of your ffmpeg, i think the ubuntu repo version doesn’t include ‘libmp3lame.so.0’ and some other modules.

  5. This also didn’t work for me. The very first instruction needs expanding: don’t just uninstall ffmpeg but also uninstall libavcodec1d. Then the medibuntu versions can get installed, and now it works for me. (Well, it now shows lame in the ldd output now – I’ve not actually tried mp3 stuff yet.)

  6. Whatever I do with ffmpeg the line:

    ffmpeg -i familyguy.avi -acodec mp3 -ar 44100 -f flv fg.flv

    always ends in:

    Unknown encoder ‘mp3’

    I’ve tried uninstalling and installing various libs and such, manually and with apt. I don’t get it.

    Doing ldd on the ffmpeg-bin I get:

    linux-gate.so.1 => (0xb7f7d000)
    libavdevice.so.52 => /usr/lib/i686/cmov/libavdevice.so.52 (0xb7f6c000)
    libavformat.so.52 => /usr/lib/i686/cmov/libavformat.so.52 (0xb7ece000)
    libavcodec.so.51 => /usr/lib/i686/cmov/libavcodec.so.51 (0xb7980000)
    libavutil.so.49 => /usr/lib/i686/cmov/libavutil.so.49 (0xb7971000)
    libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb794b000)
    libswscale.so.0 => /usr/lib/i686/cmov/libswscale.so.0 (0xb791f000)
    libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7906000)
    libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb77aa000)
    libdc1394.so.22 => /usr/lib/libdc1394.so.22 (0xb773d000)
    libX11.so.6 => /usr/lib/libX11.so.6 (0xb764e000)
    libXext.so.6 => /usr/lib/libXext.so.6 (0xb7640000)
    libz.so.1 => /usr/lib/libz.so.1 (0xb762b000)
    libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7627000)
    libfaad.so.0 => /usr/lib/libfaad.so.0 (0xb75e7000)
    libgsm.so.1 => /usr/lib/libgsm.so.1 (0xb75da000)
    libtheora.so.0 => /usr/lib/libtheora.so.0 (0xb7593000)
    libvorbisenc.so.2 => /usr/lib/libvorbisenc.so.2 (0xb749a000)
    libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0xb7472000)
    /lib/ld-linux.so.2 (0xb7f7e000)
    libraw1394.so.8 => /usr/lib/libraw1394.so.8 (0xb746b000)
    libxcb-xlib.so.0 => /usr/lib/libxcb-xlib.so.0 (0xb7469000)
    libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb7451000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0xb744e000)
    libogg.so.0 => /usr/lib/libogg.so.0 (0xb7449000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb7443000)

    Any thoughts?

Leave a Reply

Your email address will not be published. Required fields are marked *