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! 🙂


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!

Bookmark the permalink.

About Owen

Electrical/Electronic Engineer

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

  1. Christoffer says:


    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

    • Owen says:

      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,

  2. Christoffer says:

    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

    • Owen says:

      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,

  3. Kike says:

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

    • Owen says:

      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,

  4. DomoJimbo says:

    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. Phil Borman says:

    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. Pingback: Raspberry Pi: Compilando o ffmpeg | Diário de TI

  7. Lloyd says:

    Seems like the url of LibVPX has changed.

    sudo git clone

    sudo git clone

  8. Rune says:

    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

  9. Scriptman says:

    Thanks for works great on ARM Scaleway Server
    i tested it via command line and it convert the video without any problem.

  10. paddyg says:

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

    Thanks for all this, by the way!

  11. paddyg says:

    Hi again, libvpx seems to have moved!!

    git clone

  12. Jeroen says:

    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,

    • Jeroen says:

      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…

    • Owen says:

      You probably forgot to run this inside the directory;

      sudo make install

      if that didn’t work, try;

      sudo ldconfig

      Kind Regards,

  13. Mike says:

    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?


    • Owen says:

      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,

  14. Mike says:

    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!

    • Owen says:

      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.

      • pix3l says:

        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

  15. Davide says:

    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?

  16. Peter Wilson says:

    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.

  17. ian flitman says:

    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 $ ./ –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

    any ideas?

    • Owen says:

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

    • akitolong says:

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

      thanks to paddyg

  18. Pingback: Le blog Webnet – via @Webnet_France | Comment créer un assistant d’accueil avec Raspberry Pi ?

  19. Prakash says:

    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 :

    owen, can you update this ?
    Thanks for your tutorial

    • Owen says:

      Hi Prakash,

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

      Kind Regards,

  20. Rudraksh says:

    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.

  21. rudraksh says:

    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.

  22. Anna says:

    Hi, you can stream video to Local web by ffmpeg at here, visit this link

  23. Barry D. says:

    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: 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:~ $


    Thanks again,

  24. Xouthos says:

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

    ./configure –target=armv6-linux-gcc

    … when compiling libvpx?

  25. Gene says:

    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: cannot open shared object file: No file or directory

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

  26. Chris says:

    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.

    • Owen says:

      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.

  27. Wolf says:

    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?


  28. Wolf says:

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


    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!

  29. mutsys says:

    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
    cd libvpx
    git checkout v1.6.0
    ./configure –target=armv6-linux-gcc
    sudo checkinstall –pkgname=libvpx –pkgversion=”1:$(date +%Y%m%d%H%M)-git” –backup=no –deldoc=yes –fstrans=no –default

  30. seb says:

    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’.

  31. Nitrofx says:

    Excellent tutorial. Great work. Thank you.

  32. Nitrofx says:

    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

  33. Pingback: Compiling ffmpeg for audio and video streaming in a Raspberry Pi – antonio luppi

  34. Christian Schafleitner says:

    Hey! Thanks a lot for this great tutorial.
    I run into an issue compiling rtmpdump:

    make[1]: Entering directory ‘/home/pi/src/rtmpdump/librtmp’
    gcc -Wall -DRTMPDUMP_VERSION=\”v2.4\” -DUSE_OPENSSL -O2 -fPIC -c -o rtmp.o rtmp.c
    In file included from handshake.h:86:0,
    from rtmp.c:152:
    dh.h: In function ‘DHInit’:
    dh.h:256:12: error: dereferencing pointer to incomplete type ‘DH {aka struct dh_ st}’
    dh.h:171:19: note: in definition of macro ‘MP_new’
    #define MP_new(m) m = BN_new()
    In file included from rtmp.c:152:0:
    handshake.h: In function ‘InitRC4Encryption’:
    handshake.h:120:12: error: storage size of ‘ctx’ isn’t known
    HMAC_CTX ctx;
    In file included from rtmp.c:152:0:
    handshake.h:72:35: warning: implicit declaration of function ‘HMAC_CTX_init’ [-W implicit-function-declaration]
    #define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0)
    handshake.h:125:3: note: in expansion of macro ‘HMAC_setup’
    HMAC_setup(ctx, secretKey, 128);
    handshake.h:74:67: warning: implicit declaration of function ‘HMAC_CTX_cleanup’ [-Wimplicit-function-declaration]
    #define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_clea nup(&ctx)
    handshake.h:127:3: note: in expansion of macro ‘HMAC_finish’
    HMAC_finish(ctx, digest, digestLen);
    In file included from rtmp.c:152:0:
    handshake.h:120:12: warning: unused variable ‘ctx’ [-Wunused-variable]
    HMAC_CTX ctx;
    handshake.h: In function ‘HMACsha256’:
    handshake.h:269:12: error: storage size of ‘ctx’ isn’t known
    HMAC_CTX ctx;
    handshake.h:269:12: warning: unused variable ‘ctx’ [-Wunused-variable]
    rtmp.c: In function ‘RTMP_ReadPacket’:
    rtmp.c:3555:7: warning: variable ‘didAlloc’ set but not used [-Wunused-but-set-v ariable]
    int didAlloc = FALSE;
    At top level:
    rtmp.c:2907:19: warning: ‘av_NetConnection_Connect_Rejected’ defined but not use d [-Wunused-const-variable=]
    static const AVal av_NetConnection_Connect_Rejected =
    rtmp.c:1559:35: warning: ‘av_record’ defined but not used [-Wunused-const-variab le=]
    #define SAVC(x) static const AVal av_##x = AVC(#x)
    rtmp.c:1905:1: note: in expansion of macro ‘SAVC’
    : recipe for target ‘rtmp.o’ failed
    make[1]: *** [rtmp.o] Error 1
    make[1]: Leaving directory ‘/home/pi/src/rtmpdump/librtmp’
    Makefile:76: recipe for target ‘librtmp/librtmp.a’ failed

    I am trying install this on Raspian Stretch, so maybe the OpenSSL version is slightly different to Jessie.
    Any advice someone?


  35. Simon O says:

    Same, unfortunately. I tried use Polaris SSL instead and had even less luck (

  36. acrobal says:


    I am getting exactly the same error message as Christian Schafleitner when trying to;
    make SYS=posix

    to solve it :

    apt-get install libssl-dev

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.