Up-to-date ffmpeg on Ubuntu Hardy

The Ubuntu repositories will give you a crippled, antiquated version of ffmpeg. Here’s the latest in my occasional series of explanations of how to get a newer, better, more full-featured version.

First, make sure that your system is up-to-date:

sudo apt-get update
sudo apt-get upgrade

Next, get your dependencies:

sudo apt-get build-dep ffmpeg
sudo apt-get install liblame-dev libfaad-dev \
libfaac-dev libxvidcore4-dev liba52-0.7.4 \
liba52-0.7.4-dev libx264-dev libdts-dev \
libgsm1-dev \
checkinstall build-essential subversion

Grab the ffmpeg source:

svn co -r 14946 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

Patch ffmpeg to work with Hardy’s slightly older x264 library (i.e. remove TESA support):

cd ffmpeg
wget http://po-ru.com/files/ffmpeg-14946-hardy.patch
patch -p0 < ffmpeg-14946-hardy.patch

Configure and build:

./configure --enable-gpl --enable-postproc \
--enable-libvorbis --enable-liba52 --enable-libdc1394 \
--enable-libgsm --disable-debug --enable-libmp3lame \
--enable-libfaad --enable-libfaac --enable-libxvid \
--enable-pthreads --enable-libx264
make

And install (I set the version to 3:1.svn14946):

sudo checkinstall

It works for me, but if I’ve missed a step or a dependency, shout in the comments.

Comments

  1. Dana

    Wrote at 2008-08-30 01:52 UTC using Firefox 2.0.0.14 on Linux:

    When I run ./configure, I get the error:

    ERROR: libgsm not found
  2. transzoo

    Wrote at 2008-08-30 11:58 UTC using Firefox 3.0.1 on Mac OS X:

    @Dana: When you run in to problems like that do a Google search for the package and add words like ubuntu and package. I had several missing and found what packages I had to install with that method. Most them had a -dev at the end. For libgsm it was quite literalley libgsm-dev. Hope that helps!
  3. Paul Battley

    Wrote at 2008-08-31 14:27 UTC using Firefox 3.0.1 on Linux:

    I had missed libgsm1-dev. I’ve added it to the list of prerequisites.
  4. kAos

    Wrote at 2008-09-03 14:11 UTC using Firefox 3.0 on Linux:

    It compiled and installed for me okay, but when I run it:

    /usr/local/bin/nuvexport—infile /var/lib/mythtv/recordings/1001_20080902223500.mpg—noconfirm into: /home/Tmp/Mythtv

    ... it bails out saying:

    ffmpeg had critical errors:
    av_interleaved_write_frame(): Error while opening file

    ... before it manages to process the first frame. Google didn’t bring up anything on this error. Has anyone seen/solved this one?
    Thanks.
  5. GC

    Wrote at 2008-09-07 18:59 UTC using Firefox 3.0.1 on Linux:

    Works Great!!!
    Thank you
  6. CK Rock

    Wrote at 2008-09-14 03:29 UTC using Firefox 3.0.1 on Linux:

    I use this series every time I reinstall (k)ubuntu. You’re awesome! Thanks for providing this service!
  7. mdkaneda55

    Wrote at 2008-09-14 10:49 UTC using Firefox 3.0.1 on Linux:

    Awesome! i’m glad i stumbled onto ur guide, i hate trying to figure out dependencies when compiling. =) this makes it a breeze! This is definitely going into my bookmarks! hehe. thanx a ton!!
  8. Paul Battley

    Wrote at 2008-09-14 12:24 UTC using Firefox 3.0.1 on Linux:

    I’m glad you’re finding it useful.

    If you have any problems during compilation, or afterwards, when using it, please come back and add a comment here.
  9. Allan Morris

    Wrote at 2008-09-20 10:40 UTC using Firefox 3.0.1 on Linux:

    Downloaded and compiled fine. Guide great help, thanks. Now testing to get good quality at reasonable bitrate / size.
  10. Dan

    Wrote at 2008-09-21 09:28 UTC using Firefox 3.0 on Unknown OS:

    You can add ’- -enable-libtheora’ to the configure line, and ’- -cpu=core2’ for further optimisations, if you have a core2duo processor.

    Also, the package ‘libmp3lame-dev’ deprecates ‘liblame-dev’ in Intrepid (maybe Hardy too).

    Thanks! Dan
  11. Keith Hughitt

    Wrote at 2008-09-22 20:01 UTC using Firefox 3.0.1 on Linux:

    Hey Paul,

    Thanks for the guide! The above worked great for me on 8.10. I was wondering if you have any experience with watermarking videos? So far I haven’t been able to get vhook to work on Ubuntu.

    Any ideas?
  12. Jeffrey H

    Wrote at 2008-09-22 20:51 UTC using Firefox 3.0.1 on Linux:

    Worked great for me! I’ve tried so many things to get it working and this did it. Thanks for this straightforward guide.
  13. Mimzy

    Wrote at 2008-09-25 21:49 UTC using Firefox 3.0.2 on Linux:

    I get stuck on the “checkinstall build-essential subversion” part…I get a message that says “The package documentation directory ./doc-pak does not exist.”

    It then offers to make a “default set of docs”, but I’m pretty new to linux and have no idea what this means. Could someone please help?
  14. Theo Bunge

    Wrote at 2008-10-12 14:02 UTC using Firefox 3.0.3 on Linux:

    Thanks for the help compiling ffmpeg for Ubuntu Hardy, and also all the trouble to run a service like this. Everything works fine.
    Greetings
    Theo from South Africa
  15. DallasP

    Wrote at 2008-10-16 03:24 UTC using Safari 525.20.1 on Mac OS X:

    I had to drop—enable-libvorbis—enable-libdc1394 to get the configure. The output showed these were turned off as a result.
  16. Freddy

    Wrote at 2008-10-19 20:39 UTC using Firefox 3.0.3 on Linux:

    Hi Paul,

    thanks for the guide. Trying to compile, but got this error:

    -c -o libavformat/tcp.o libavformat/tcp.c
    gcc -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I. -I”/home/freddy/Desktop/ffmpeg” -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -fasm -std=c99 -fomit-frame-pointer -pthread -Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wtype-limits -O3 -fno-math-errno -fno-signed-zeros -c -o libavformat/udp.o libavformat/udp.c
    libavformat/udp.c: In function ‘udp_join_multicast_group’:
    libavformat/udp.c:83: error: storage size of ‘mreq’ isn’t known
    libavformat/udp.c:83: warning: unused variable ‘mreq’
    libavformat/udp.c: In function ‘udp_leave_multicast_group’:
    libavformat/udp.c:111: error: storage size of ‘mreq’ isn’t known
    libavformat/udp.c:111: warning: unused variable ‘mreq’

    Running intrepid.
    Thank you
  17. scalpel4hire

    Wrote at 2008-10-23 13:27 UTC using Firefox 3.0.3 on Linux:

    Get the same hitch as mimzy – stuck at “checkinstall build-essential subversion”
    & not sure how to proceed with the “default set of docs” preparation (seems to expect some parameters, of which I have no idea.)
    Did you figure this out, mimzy?
  18. TehSnarf

    Wrote at 2008-10-23 17:26 UTC using Firefox 3.0.3 on Windows Vista:

    Yeah, just got the same error as Freddy… could also use some help on that.
  19. JoeLinux

    Wrote at 2008-10-26 16:56 UTC using Firefox 3.0.3 on Linux:

    I got it working in Intrepid. You have to download the latest revision from svn:

    svn co svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

    Once that downloads, follow the same steps above (even the hardy patch still works). Before you run the configure statement, you must install the latest x264 version first (this revision asks for a version of x264 >= 0.65, while Ubuntu only offers at most version 0.59). To do this, grab the latest version from http://www.videolan.org. You can install either via tarball or git repository (I used git).

    Then, once you’ve completed installation of x264 and finally get to the “configure” portion, use this configure statement:

    ./configure—enable-gpl—enable-postproc—enable-libvorbis—enable-libdc1394—enable-libgsm—disable-debug—enable-libmp3lame—enable-libfaad—enable-libfaac—enable-libxvid—enable-pthreads—enable-libx264

    Before you type “make” there are a few other things that it looks for. I had to install both libpostproc-dev and libavdevice-dev, and also do the following:

    sudo ln -s /usr/include/postproc/ /usr/local/include/libpostproc
    sudo ln -s /usr/include/ffmpeg/ /usr/local/include/libavdevice
    sudo ln -s /usr/include/ffmpeg/ /usr/local/include/libavformat
    sudo ln -s /usr/include/ffmpeg /usr/local/include/libavcodec
    sudo ln -s /usr/include/ffmpeg /usr/local/include/libavutil
    sudo ln -s /usr/lib/vhook /usr/local/lib/vhook

    There must be a cleaner way of doing that (maybe PREFIX=/usr somewhere?). Anyway, it works. Then run “make” and “sudo checkinstall”. That’s it!
  20. Oliver

    Wrote at 2008-11-08 04:52 UTC using Firefox 3.0.3 on Linux:

    I’ve been trying to transcode the ac3 audio from an AVCHD file to mp2, and I get

    Unsupported codec (id=86020) for input stream #1.0

    Am I missing a dependency, or should I change the configuration before building?
  21. jani

    Wrote at 2008-11-08 14:45 UTC using Firefox 3.0.3 on Linux:

    Thanks,

    Short and sweet: This guide gave me couple of extra hours to play with the kids and the dog.

    My MythTV was running out of disk space and and now I can transcode movies eith H.264.

    Cheers,

    Jani
  22. jim

    Wrote at 2008-11-14 04:57 UTC using Firefox 3.0.3 on Linux:

    Just tried this on 8.10 when I discovered that ffmpeg has been disabled to prevent any transcoding to DivX.

    Perhaps unsurprisingly it doesn’t work on “Intrepid”. First problem was that the liblame library has been renamed to libmp3lame, and the dev library correspondingly.

    When I do the make, I get the following error, which I have to confess I don’t really know enough to solve.
    libavformat/udp.c: In function ‘udp_join_multicast_group’:
    libavformat/udp.c:83: error: storage size of ‘mreq’ isn’t known
    libavformat/udp.c:83: warning: unused variable ‘mreq’
    libavformat/udp.c: In function ‘udp_leave_multicast_group’:
    libavformat/udp.c:111: error: storage size of ‘mreq’ isn’t known
    libavformat/udp.c:111: warning: unused variable ‘mreq’
    make: *** [libavformat/udp.o] Error 1

    Hopefully this will help someone, or at least save someone some time. Shame it doesn’t work as there are a lot of good things happening with 8.10.
  23. orbitalgun

    Wrote at 2008-12-04 03:03 UTC using Firefox 3.0.4 on Mac OS X:

    jim: yeah, i’m mb ibex too. not a programmer, don’t know where the problem really lies… but i googled “udp.o error 1 ffmpeg” and found http://www.opensolaris.org/jive/thread.jspa?threadID=84354&tstart=0 which mentions adding ”—disable-protocol=udp” to the configure line. not sure yet how this will impact what i’m trying to do (automagic commflag+transcode to xvid from myth). either way, it DOES compile, albeit w/o udp support i guess. we’ll see how many more miles i can ride THIS crazy torpedo before it blows up in my face.

    o
  24. orbitalgun

    Wrote at 2008-12-04 18:56 UTC using Firefox 3.0.4 on Mac OS X:

    jim,

    it did compile, but failed to install throwing:

    install -d ”/usr/local/include/libpostproc”
    install: cannot change permissions of `/usr/local/include/libpostproc’: No such file or directory
    make: *** [install-headers] Error 1

    i’m trying http://pennsylvania.ubuntuforums.com/showthread.php?s=703c6ccf30ab7f3fb0afa5cc45f65126&t=786095 for the compile. it’s ibix-centric.

    yes… i know there are plenty of people who could look at that error and go “why didn’t you just framulate the thingbadger, grab a coffee and it’s all joy”, but again, i’m no programmer, i rely on posts like the two i’ve linked to and hundreds of others to get me thru.

    i’m getting close to exhausing my reserve of patience on this. i’ve been dabbling w linux since 94, and it hasn’t changed. if it hacks together and works today, it won’t (the same way) tomorrow.

    o
  25. Beth

    Wrote at 2008-12-06 01:12 UTC using Opera 9.61 on Linux:

    I’m really new to Ubuntu and therefore not that savy with running these types of things and using the terminal, so please pardon my lack of knowlege.

    I’m having problems with the “Configuration and build” part. Do I just put what’s there into the termal? Because I’ve tried it and I keep getting error messages.

    “bash: /configure: No such file or directory”

    Makes me feel really dumb, but I really need this in order to convert videos onto my iPod Classic.

    Thanks for any help you could give me!
  26. Beth

    Wrote at 2008-12-06 23:12 UTC using Opera 9.61 on Linux:

    I’ve commented before, but looking at how old this page might be, I’m not sure I’ll get a reply any time soon. Either way, I’ve decided this might not be a good idea. Even though I tried up to the configure part, I’m afraid to break something. I just hope these instructions haven’t messed up something so far. I’m assuming I won’t be able to complete them without some sort of help.
  27. Paul Battley

    Wrote at 2008-12-06 23:22 UTC using Firefox 3.0.4 on Linux:

    Beth, it looks like you typed /configure instead of ./configure—the dot is important.
  28. Beth

    Wrote at 2008-12-15 23:10 UTC using Opera 9.61 on Linux:

    I’m still having troubles. Gah. I really wish something would work. When I did manage to get the terminal to do something besides what it normally did when I did the configure part I get some document thing, and I thought I was similar to what some other people were saying. Tried some of that but it still fails to work. I really wish I could have done it right the first time, but I guess it just doesn’t want to work for me.
  29. alan blount

    Wrote at 2008-12-17 03:36 UTC using Chrome 0.4.154.29 on Windows XP:

    If you can not ./configure and are getting an error about missing “libdc1394” then you can fix with the following:

    # apt-get install libdc1394-22-dev
  30. Beth

    Wrote at 2008-12-17 20:07 UTC using Opera 9.61 on Linux:

    I don’t believe it is that—though I tried what you said (alan) and it denied me permission to do so.
  31. Phil

    Wrote at 2009-05-28 21:55 UTC using Firefox 3.0.10 on Linux:

    Do you have an updated instruction for Jaunty? Thanks.
  32. Dominique

    Wrote at 2009-08-05 03:08 UTC using Firefox 3.0.12 on Linux:

    Hi, Paul,

    Thanks for this very instructive how-to. I adapted the steps for Jaunty, and it works fine. Here’s my own documentation: http://ubuntuliving.blogspot.com/2009/08/compiling-ffmpeg-that-can-transcode-to.html

    I omitted liba52 as it produced an error during compilation. I also had to include the non-free option.
    —Dom
  33. vdp

    Wrote at 2009-08-05 11:44 UTC using Firefox 2.0.0.16 on Windows XP:

    Вещание видеофайлов с помощью VLC multicast / IPTV

    to solve it (avcodec encoder error: cannot find encoder MPEG-2 Video, *** Your FFMPEG installation is crippled. ***) run:
    sudo apt-get install libavcodec52 libavcodec-dev
  34. newdev

    Wrote at 2009-08-05 15:03 UTC using Firefox 3.0.13 on Linux:

    Hi every body,
    I know it isn’t the suitable place to make this question but I think that you can help me. I am looking for multimedia adaptation modules that allow me to modify an input video in order to be adapted to the usage environment. Do you any of them?
  35. alun

    Wrote at 2009-10-29 15:33 UTC using Firefox 3.0.14 on Linux:

    Paul, Many thanks for iplayer-dl and this information on ffmpeg.

    For info, found this link very helpful for installation of ffmpeg on ubuntu ‘Jaunty’.

    (That’s http://ubuntuforums.org/showthread.php?t=786095 if I haven’t formatted link correctly!)
  36. Lasagna

    Wrote at 2009-12-24 14:48 UTC using Firefox 3.5.6 on Windows Vista:

    It worked perfectly !!! I used it for the ClipCenter Youtube Software script at http://www.clip-center.com ,they require a ffmpeg-server to be configured for their youtube clone
  37. Mathias Rav

    Wrote at 2010-01-28 22:55 UTC using Chrome 5.0.308.0 on Linux:

    Unfortunately, revision 14946 from September 2008 is no longer supported by current libraries, and it would probably be wise to use a newer version regardless. I tried updating partly but to no avail… I’ll try again some other time, with the HEAD revision (around rev 23000 I think)
  38. Jayaraj K

    Wrote at 2012-11-27 14:33 UTC using Firefox 7.0.1 on Linux:

    http://allofit.blog.com/

    This covers ffmpeg compilation on ubuntu on step by step basis.