Compiling ffmpeg with mp3 on Ubuntu - Revised for Ubuntu Gutsy Server

12 MAY 2008 / joeri poesen

This is a revised edition of my original post on compiling ffmpeg on Ubuntu.

update: seems to work in Hardy too.

The excellent Flashvideo module in Drupal uses ffmpeg to convert uploaded video to Adobe Flash Video format (.flv).

However, we’re using Ubuntu based servers and Ubuntu has a strict policy not to include non-free software. This means that the ffmpeg version in the repositories is not built with essential functionality, like mp3 support for audio conversion.

Solution: compile from source. Don’t run away screaming. It’s real easy.

1. enable universe and multiverse repositories
UbuntuGuide » general notes » how to add extra repositories

2. get your tools

sudo apt-get install checkinstall build-essential subversion

3. get the latest ffmpeg sources

cd /usr/local/src
sudo svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

4. get the necessary dependencies

sudo apt-get install liblame-dev libfaad-dev libfaac-dev libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev 

5. configure

cd ffmpeg
sudo ./configure --enable-gpl --enable-liba52 --disable-debug --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-pthreads --disable-vhook

6. compile

sudo make

7. go have a snack

8. create the .deb package

sudo checkinstall

note: just press [return] each time when asked for a configuration option

9. install the .deb package

sudo dpkg -i [ffmpeg_your_version.deb]

10. rejoice

Comments

Hi

Step 5 should be done inside /usr/src/ffmpeg. So 'cd ffmpeg' in step 6 is to late :P

And because you do a sudo svn action, all actions after that should also have sudo in front.

That's all.

Thanks. Updated as per your suggestions.

J.

What about medibuntu ? ....

Hi Joeri,
I had the same problem, but not the same solution.
I choose to add the medibuntu repository (as founded on http://www.medibuntu.org/ or http://doc.ubuntu-fr.org/depots) were you can find a .deb file to intall or update ffmpeg including the mp3 support.
As this ffmpeg is updated including the mp3 support, wich I guess is not the case with compilation.
Good to know.
See you ;-)
Gregoire.

I followed the instructions without a hitch, but still get the following error when attempting to trasnscode from avi to wmv, using the mp3 codec.

(I am using Ubuntu Gutsy)

stream_out_transcode debug: creating audio transcoding from fcc=`mpga' to fcc=`mp3 '
main debug: looking for decoder module: 25 candidates
main debug: using decoder module "mpeg_audio"
main debug: looking for encoder module: 8 candidates
ffmpeg debug: libavcodec already initialized
ffmpeg error: cannot find encoder MPEG Audio layer 1/2/3
stream_out_transcode error: cannot find encoder ((null))
main debug: removing module "mpeg_audio"
stream_out_transcode error: cannot create audio chain
main error: cannot create packetizer output (mpga)

Am I wrong that "cd ffmpeg" should be at the beginning of step 5 "configure", not 6 "compile"?
When i tried the ./configure ... thing in /usr/local/src, it said that the command was not found, so i guessed i might cd ffmpeg...
Right now my computer is "make"ing, so I'll be back in a while (after step 7 "snack"), to tell you if it is working for me
(c:

You're absolutely right. The 'cd ffmpeg' should have been mentioned in step 5, not step 6. This is now corrected.

Thanks.
J.

Steps 5 and 6 are a little confusing.

Also, if you sudo svn checkout, you'll have to sudo to configure and build, so I'd submit the following changes

3:
cd /usr/local/src
sudo (mkdir ffmpeg; chown $USER ffmpeg)
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

5:
cd ffmpeg
./configure ....

6:
make

Thanks for this, it works in Hardy too.

Hint: look up the current version numbering scheme that Ubuntu uses to avoid having software update overwriting your custom ffmpeg. I used 3:0.cvs20080624 . If you keep the default version number ( 20080624 today ), software update will offer you an 'updated' ffmpeg version.

Great, thank you!
Works like a copy and paste on hardy :)

thanks for the walkthrough. you couldn't have made it any easier. Cheers!

Hey, AWESOME tutorial, thanks!

Having a problem with step 5. Here's what I get:
Unknown option "--enable-liba52".
See ./configure --help for available options.

When I do, ./configure --help, it doesn't show the option for --enable-liba52. I ran across this site,http://xbmc.org/trac/ticket/4774, and wasn't sure if it was XBMC specific or applied to ALL FFMPEG.

Either way, it worked like a charm after I removed "--enable-liba52"

Cheers!

Good post. realy good post thx :-)

Hmm 'make' isn't working for me..
Makefile:1: config.mak: No such file or directory
libavdevice/Makefile:1: libavdevice/../config.mak: No such file or directory
libavformat/Makefile:1: libavformat/../config.mak: No such file or directory
libavcodec/Makefile:1: libavcodec/../config.mak: No such file or directory
libavutil/Makefile:1: libavutil/../config.mak: No such file or directory
libswscale/Makefile:1: libswscale/../config.mak: No such file or directory
make: *** No rule to make target `libswscale/../config.mak'. Stop.

woop hold it... I had to take of liba52 and vhook, and also add --enable-free something then it worked

quick note for ubuntu 9.10,

I had to change liblame-dev to libmp3lame-dev

thanks for the great tutorial!

another quick note, had to change the configuration command to:

sudo ./configure --enable-gpl --disable-debug --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-pthreads --enable-nonfree

Thanks, d. That reminds me it's high time to update the tutorial again.

Cheers!
J.

Post new comment

The content of this field is kept private and will not be shown publicly.