How to install FFMPEG, Libx264, LibRTMP, LibAACPlus, LibVPX on the Raspberry Pi (Debian “Wheezy” ARMHF)

In the past I’ve had to been required to install FFMPEG for applications such as Serviio or a website like Clipbucket. It can be quite stressful since you could get dependency issues if you tried reading any other tutorials online, since the worst nightmare is if something breaks when you have compiled software using wrong dependencies. But this tutorial should ensure that it’ll work first time.

 UPDATE (12/10/2016): I’ve since updated this tutorial to add two new codecs for FFMPEG. I’ve also changed the FFMPEG repository to the official one rather than VideoLan. I’ve tested this complete tutorial for my Raspberry Pi 3 and it works fine.

Removing any existing dependencies

It’s vital to uninstall everything we’re going to be compiling/installing just in case there have been custom compilations of software that might be corrupted or broken. I’ve had a few errors in the past which resulted in “Illegal Instruction” when executing “ffmpeg” in the terminal.

Just copy and paste this into your terminal and hit enter. Type y and hit enter when necessary.

Downloading the Dependencies

Copy and Paste the commands below. When it asks, type and press Enter. This will download and install everything we need for later on.

Downloading & Compiling FFMPEG AND It’s Modules

Before we get started, we will be working inside a folder within the home directory. It is important not to remove this file in-case you want to uninstall anything later. Type the commands below in order and follow through.

Downloading & Compiling LibaacPlus

Again, type the below commands in order, and then move onto the next step.

Downloading & Compiling Libx264

 Downloading & Compiling LibVPX

NOTE: if you see the command output for “./configure” incorrectly identify the Pi as ArmV7 instead of ArmV6, try running the configure command again with the following parameter;

Downloading & Compiling LibRTMP

Now, before we move on, it’s important to run the command

This will update the system and make it aware of the new packages which have been installed.

Downloading & Compiling Libfaac

When you’re in the nana editor, you will need to go to line 126. Once you’re at that line, make the below code the same as in the file…

Once you’re finished, press CTRL + O to save, and then hit enter, then press CTRL + X to close the editor.

Then carry on…

It’s important to do a reboot just to make sure everything is being recognised and found.

Downloading & Compiling LibFDK-aac

Downloading & Compiling FFMPEG (Latest Version)

NOTE: This took my Raspberry Pi (Model B) around ~2 hours when overclocked to “Turbo” – 1GHz.

Finishing up

Now that FFMPEG has been compiled and installed successfully, we will need to reboot to make sure that everything is working. Type in;

When the Pi boots up, type in “ffmpeg” and you should see an output similar to that of what I get below;

And that’s it! You have now successfully installed FFMPEG on your Raspberry Pi! 🙂

Summary

The Raspberry Pi is a small credit-card sized computer. It’s very low powered and can be powered by a mini-usb cable and USB plug, such as a modern day phone charger. The Raspberry Pi (Model B) has a stock 700Mhz Armv6 processor and 512MB of RAM. The processor can be overclocked in the configuration to a maximum of 1Ghz (WARNING – Overclocking the Pi may void your warranty and break it).

When software utilises FFMPEG, you will see that it may bring the processor usage to 100% on the pi. This will cause the SoC to heat up rapidly unless you have a heatsink or some other form of cooling. At 100% CPU utilisation, the temperature without a heatsink can reach up to 80 Degrees Celsius!

Feel free to comment below and ask any questions!

56 Replies to “How to install FFMPEG, Libx264, LibRTMP, LibAACPlus, LibVPX on the Raspberry Pi (Debian “Wheezy” ARMHF)”

  1. Hello

    I followed this excellent tutorial for my rapsberry pi. But when everything is completed I get “Illegal instruction” when I try to convert a video file to mp4 using ffmpeg… I can convert the file to flv as long as I dont use libx264, then I get the error message again.

    Do you have any idea why? I have spent countless hours trying to solve the issue and search the web.

    Best regards
    Chris

    1. Hi Chris,

      Thank you! I really appreciate your comment.

      I received the same error when I tried installing it on my Raspberry Pi after reading countless tutorials. Unfortunately, I had to do a clean install and start again. If it isn’t to much, backup everything, and wipe your SDCard, then apply the latest Debian version from the Raspberry Pi website. Once you’re logged into SSH with a fresh install, move everything back over to your Raspberry Pi (from which you backed up) then follow this tutorial again. It should work straight away then.

      I believe the error is because it is still picking up the software packages on your system which you installed via apt-get from tutorials, or from compiling. When you uninstall a piece of software by doing “make uninstall” some files may still exist on the system, which has proven to be a nightmare.

      I hope I helped!

      Kind Regards,
      Owen.

  2. Hello Owen!

    Thank you very much for your reply, I really appreciate it! I have been testing all kinds of things including older versions of ffmpeg but without any luck… Unistalling libx264 and ffmpeg completely seems to be problematic.

    I recently realized what you now gave as a suggestion… Maybe it is time to do a clean install.

    The tutorial you made here was excellent indeed! Keep up the good work.

    Best Regards
    Chris

    1. Hi Chris,

      Thank you once again, I really appreciate it!

      I went through the same problem when I was trying to install ffmpeg. Luckily this solution worked for me, and I just didn’t touch it once it was done. I tried compiling ffmpeg again last night once I backed up, using libfaac, but it turned out that it caused the illegal instruction also. Its just trial and error, but it is annoying having to wait ~2 hours for ffmpeg to compile to see if it worked or not.

      I’ll be adding a few lines in the beginning of the article when I get around to it, for making sure that some of the packages which aren’t working which people installed aren’t breaking ffmpeg.

      Thanks once again!

      Kind regards,
      Owen.

  3. I did a clean install of Raspbian and I followed your tutorial, but I’m still receiving “Illegal instruction” when using libx264.

    1. Hi Kike,

      I’m unsure how this happening as this tutorial was what worked for me on a clean install. Did you install the optional package, Libfaac? I wouldn’t recommend it since it can cause the “Illegal Instruction” error.

      Kind regards,
      Owen.

  4. Hi Owen, Hi all,

    I succeed to compile ffmpeg on a fresh Raspbian as suggested.
    But my issue is that ffplay is not built, do you know why and most important how to solve the problem ? with dependancy is missing ?
    Thanks in advance

  5. Just followed your tutorial on OSMC on a raspberry pi2
    By default this doesn’t include pkg-config so I had to
    sudo apt-get install pkg-config
    with the other dependencies. Just a heads-up as you dont get an error until configuring ffmpeg

  6. Hi,
    I get an error message when compiling x264 according to your instructions. Any idea what may cause it?
    ~/src/x264 $ make
    dependency file generation…
    gcc -Wshadow -O3 -ffast-math -Wall -I. -I. -std=gnu99 -mcpu=cortex-a8 -mfpu=neon -I/usr/local/include -I/usr/local/include -fomit-frame-pointer -fno-tree-vectorize -c -o x264.o x264.c
    x264.c: In function ‘print_csp_names’:
    x264.c:445:15: error: variable ‘i’ has initializer but incomplete type
    x264.c:445:27: error: storage size of ‘i’ isn’t known
    x264.c:445:5: error: ‘enum PixelFormat’ declared in ‘for’ loop initial declaration
    x264.c:445:27: warning: unused variable ‘i’ [-Wunused-variable]
    : recipe for target ‘x264.o’ failed
    make: *** [x264.o] Error 1

  7. Hi, just redoing this on a new jessie sd card and the test in libaacplus autogen.sh
    libtool –help
    fails, as the actual command used later is libtoolize, changing to that fixes it.

    Thanks for all this, by the way!

  8. Hi Owen,

    I have an unusual problem and I couldn’t find a solution or similiar problem in the comments.
    I followed your tutorial step by step and it was very helpful.
    I skipped the optional as I didn’t want any problems created from that module.
    However after rebooted and typed in ffmpeg its says command not found.
    Now when I go to the path /home/pi/src all the files and folders are there, executeables included. But I cannot get it to work.
    Do you have any idea what the underlying issue could be?

    Best regards,
    J

    1. I have found the issue. I have not configured ./configure –arch=armel –target-os=linux –enable-gpl –enable-libx264 –enable-nonfree –enable-libaacplus –enable-librtmp –enable-libmp3lame correctly. I left out libmp3lame I remove the whole step from my Pi and when I tried again it said. Error: libmp3lame >= 3.98.3 not found Strange…

    2. You probably forgot to run this inside the directory;

      sudo make install

      if that didn’t work, try;

      sudo ldconfig

      Kind Regards,
      Owen

  9. Hi Owen,

    Your tutorial is going to be my last go at ffmpeg. i’ve tried a million tutorials and stuck on ‘illegal instruction’ as a result for both ffmpeg and libav-tools avconv. Wit’s end hardly does my experience justice. Watching my pi compile for 4 hours only to see it fail during the ‘make’ process was heartbreaking.

    First i will try your tutorial on my current borked pi box, hopefully removing all the dependencies will suffice. if not, i’ll perform a recovery and start from a fresh install of the OS. Would hate to go that route, but if i gotta, i will.

    My only question to you is.. the title of your tutorial is “Debian “Wheezy” ARMHF” … i am running Raspbian (Debian 8.0 Jessie). Will your tutorial work for it or am i just wasting my time?

    Thanks!

    1. Hi Mike,

      Thanks for your message. The tutorial was aimed at the Raspberry Pi running that exact operating system, so I’m not sure if it’ll work on other OS’s as this is the only one I work with. I too tried numerous tutorials and kept getting the illegal instruction error, however this tutorial I put together seemed to work fine on a clean install. When I tried it on a borked pi with the annoyingly “illegal instruction” error, it seemed to still throw that error, which means it’s linking to a borked library somewhere on the system.

      My advice is to not add any unofficial repositories to the sources.list file for apt-get. It may install fine, but it may be broken for the pi.

      Now to answer your question, I’m guessing that it _might_ work. ARMHF meaning it’s hard-floating point.

      I’d give it ago and if it doesn’t work, I’ll try and help you.

      Kind Regards,
      Owen

  10. Sooo close… but when trying to ./configure ffmpeg i got the following error

    Unknown option “–enable-libaacplus”.
    See ./configure –help for available options.

    What happened? I know libaacplus installed perfectly at the beginning!

    1. Try replacing the hyphons “-” manually, it may have just been the way it’s been pasted in the terminal. I get that sometimes when copying and pasting.

      1. I get the same error.
        Checking ./configure –help | grep aac shows me this:

        –enable-libfaac enable AAC encoding via libfaac [no]
        –enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no]

        So there is no option –enable-libaacplus

  11. Just tried the tutorial.

    ffmpeg’s configure complains that the option ‘enable-libaacplus’ does not exist.

    I removed and went on. Probably a version mismatch?

  12. Just finished compiling ffmpeg for the third time. The first time I left out libvpx support. The second time I got the “illegal instruction” error.

    Watching the output of the ./configure for libvpx I saw that the command had incorrectly identified the Pi as ArmV7 instead of ArmV6.

    Added “–target=armv6-linux-gcc” (use ./configure –help to get a list of the valid targets) to the ./configure command and no “illegal instruction” after I compiled ffmpeg.

    Hope this helps.

  13. Nice tutorial but I am getting a strange libtool problem. I installed it:
    sudo apt-get install libtool
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    libtool is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

    But it is not picked up when I use ./configure:
    pi@raspberrypi:~/ffmpeg/libaacplus-2.0.2 $ ./autogen.sh –with-parameter-expansion-string-replace-capable-shell=/bin/bash –host=arm-unknown-linux-gnueabi –enable-static

    You must have libtool installed to compile libaacplus.
    Download the appropriate package for your system,
    or get the source from one of the GNU ftp sites
    listed in http://www.gnu.org/order/ftp.html

    any ideas?

    1. Trying running “sudo ldconfig” and then run ./configure inside the “libaacplus-2.0.2” directory instead of ./autogen.sh

    2. it is a error in the autogen.sh and lock for
      line 38: (libtool –help) /dev/null 2>&1 || {
      you have to change libtool —?> libtoolize

      thanks to paddyg

  14. for those who have issue with the step “Downloading & Compiling LibaacPlus”

    enter below line in terminal
    sudo apt-get install libtool-bin

    then continue with the same step in this tutorial.

    only then you can use –enable-libaacplus in last step (Compiling FFMPEG)

    reference : https://github.com/madewokherd/wine-mono/issues/24

    owen, can you update this ?
    Thanks for your tutorial

    1. Hi Prakash,

      Thank you very much for your comment. I’ve updated the tutorial to reflect this fix.

      Kind Regards,
      Owen

  15. Hi, Great Tutorials ! However, When i try to make the librtmp, it says below error” rtmp.c:60:25 fatal error: openssl/ssl.h no such file or directory” can you please suggest the solution.

  16. Hi, after installing, i m not able to send stream as it says, avstream.codec is depreciated and replace with avstream.codecpar. Similar with timestamp, pls suggest how to replace that.

  17. Hi Owen, thanks for all of your hard work. I have one addition to make. After doing the “sudo make install” for FFmpeg and then rebooting I received this error message: ffmpeg: error while loading shared libraries: libfdk-aac.so.1: cannot open shared object file: No such file or directory

    After a little digging on the Internet I decided to do a “sudo ldconfig” and reboot one more time. Here’s the result:

    pi@cherrypi:~ $ ffmpeg
    ffmpeg version git-2016-10-18-a20f323 Copyright (c) 2000-2016 the FFmpeg developers
    built with gcc 4.9.2 (Raspbian 4.9.2-10)
    configuration: –enable-cross-compile –arch=armel –target-os=linux –enable-gpl –enable-libx264 –enable-nonfree –enable-libfdk-aac –enable-libvpx –enable-libopus –enable-librtmp –enable-libmp3lame
    libavutil 55. 32.100 / 55. 32.100
    libavcodec 57. 61.103 / 57. 61.103
    libavformat 57. 52.100 / 57. 52.100
    libavdevice 57. 0.102 / 57. 0.102
    libavfilter 6. 64.100 / 6. 64.100
    libswscale 4. 1.100 / 4. 1.100
    libswresample 2. 2.100 / 2. 2.100
    libpostproc 54. 0.100 / 54. 0.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…

    Use -h to get full help or, even better, run ‘man ffmpeg’
    pi@cherrypi:~ $

    Bingo!!!

    Thanks again,
    -Barry

  18. How about Raspberry Pi 3 with arm 8? Should we still be using:

    ./configure –target=armv6-linux-gcc

    … when compiling libvpx?

  19. I have gone through the installation twice, both times on a fresh install of Raspbian Jessie after running sudo apt-get update sudo apt-get upgrade.

    Both times after spending 2+ hours installing, when I finally run ffmpeg at the command line I get the following error:

    ffmpeg: error while loading shared libraries: libfdk-aac.so.1: cannot open shared object file: No file or directory

    Can someone please provide a reason / solution for this? Any insights would be greatly appreciated.

  20. So compiling works just fine on Jessie, but actually running ffmpeg just returns an Illegal Instruction no matter how I use the command. Just so people know.

    1. I recently installed a fresh version of Debian Jessie on my Pi 3 and compiled ffmpeg following my article and it worked fine.

      Was your issue on the Pi 3? If so, leave out the parameter on “./configure –target=armv6-linux-gcc” so it just becomes “./configure” in the LibVPX section.

  21. Hi – thanks for these really dummy-proof set of instructions. I tried it on a pi3 with osmc installed.

    At the final step, with
    ./configure –enable-cross-compile –arch=armel –target-os=linux –enable-gpl –enable-libx264 –enable-nonfree –enable-libfdk-aac –enable-libvpx –enable-libopus –enable-librtmp –enable-libmp3lame

    I’m running into trouble:
    ERROR: libmp3lame >= 3.98.3 not found

    I could not change into the /home/pi/src/ffmpeg directory, because that does not exist. I tried the FFmpeg instead – so this my be the problem?

    Cheers,
    Wolf

  22. Right. Fixed it – I found, that from a “virgin” osmc, the following packages are missing:

    libmp3lame-dev
    libvpx-dev
    libopus-dev
    opus-devel

    Maybe they could be included into the list of required packages?

    Anyway – you made a very good and comprehensive instruction set which is very helpful to me.

    Thank you!
    Wolf

  23. libvpx recently dropped support for the ArmV6 so if you are building for that architecture, you need to make sure that you checkout the source from the last tag that still had it. the steps are:

    git clone https://chromium.googlesource.com/webm/libvpx
    cd libvpx
    git checkout v1.6.0
    ./configure –target=armv6-linux-gcc
    make
    sudo checkinstall –pkgname=libvpx –pkgversion=”1:$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default

  24. libvpx
    I just installed the latest raspbian and upgraded

    I checkout the source from v1.6.0
    ./configure –target=armv6-linux-gcc
    after make
    make[1]: Nothing to be done for ‘all’.

  25. am getting an error when runnning the ./configure –enable-cross-compile –arch=armel –target-os=linux –enable-gpl –enable-libx264 –enable-nonfree –enable-libfdk-aac –enable-libvpx –enable-libopus –enable-librtmp –enable-libmp3lame

    ERROR: opus not found using pkg-config

Leave a Reply

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