ffmpeg on raspbian / Raspberry Pi

2016-03-16 21:03

Since http://www.jeffreythompson.org/blog/2014/11/13/installing-ffmpeg-for-raspberry-pi/ is a bit messy, here is how you can compile ffmpeg with x264 on raspbian. Changes are building in your home directory, getting just a shallow git clone and building with all CPU cores. Also no unnecessary sudo…

Read the comments below!

# In a directory of your choosing (I used ~/ffmpeg):

# build and install x264
git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
make -j 4
sudo make install
# build and make ffmpeg
git clone --depth=1 git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
make -j4
sudo make install

Read the comments below!

Hopefully someone, somewhere will provide a repository for this kind of stuff some day.

It takes just 25 minutes on a Raspberry Pi 3. Not hours or days like some old internet sources on old Raspis say.

In case you are wondering v4l2 should work with this.

Categorised in: , , , ,


  • anonymous - 2016-05-01 11:11

    Thanks for the short tutorial. Just one thing you might want to correct (or at least something for future readers). Your blog seems to have messed up the “–” (double-minus) and made “–” (dash) out of them.

  • Anonymous - 2016-05-25 04:27


    the actual repository to get ffmpeg from. hope this helps!

  • Hi!

    I would like to use ffmpeg just for audio. Is there a way to compile just that?

  • Maybe a matter of versions, but I had to write “–” instead of “-” in
    ./configure –host=arm-unknown-linux-gnueabi –enable-static –disable-opencl

    … and in the second “make -j4” to add a space like in the first one = “make -j 4”

    • hmmm the system seems to translate “double -” to “–“

      • Yeah, WordPress is being super helpful with the conversion of double dashes to a fancy typographic dash. Sorry :(

        make -j4 should work though.

  • mcgyver83 - 2016-09-19 11:40

    I’m running yours commands but
    ./configure –host=arm-linux –cross-prefix=${CCPREFIX} –enable-static –prefix=/home/user/arm –disable-avs –disable-cli –disable-opencl

    the result is
    No working C compiler found.

  • izumitelj - 2016-11-01 13:13

    ffplay won’t be compiled unless SDL 2 libraries have been installed.

  • Anonymous - 2016-11-10 22:39

    Worked like a charm!
    Now my homebridge have two dLink cameras added. ME LIKE :-)

  • Which release did you use of ffmpeg.git? I tried master and n3.2, but it does not compile:

    collect2: error: ld returned 1 exit status
    Makefile:131: recipe for target ‘ffprobe_g’ failed
    make: *** [ffprobe_g] Error 1
    make: *** Waiting for unfinished jobs….
    collect2: error: ld returned 1 exit status
    Makefile:131: recipe for target ‘ffserver_g’ failed
    make: *** [ffserver_g] Error 1
    collect2: error: ld returned 1 exit status
    Makefile:131: recipe for target ‘ffmpeg_g’ failed
    make: *** [ffmpeg_g] Error 1

  • Francesco - 2016-12-16 15:05

    Thank you for the very useful tutorial. Just one question about the line:

    ./configure –arch = armel –target-os = linux –enable-gpl –enable-libmp3lame –enable-nonfree

    Why –arch = armel and not –arch = armhf as the Raspy has the hard-float?

    Thanks again

  • Pistooli - 2016-12-29 22:01

    Thanks for the instructions… worked brilliantly… :)

  • Thanks a lot for putting together these instructions, saved me a lot of time to install the ffmpeg missing library.

  • Teo Ruscin - 2017-03-01 17:54

    In order for alsa USB devices to work properly, compile with the following:

  • So after dancing around with this I’ve noticed, x264 is CPU intensive. I hardly get 4-5 fps on the same.

    Well the RPi has a GPU and you can use h264_omx to do hardware encoding where you can get upto 25/30fps while livestreaming.

    FFPEG Config:

    sudo ./configure –arch=armhf –target-os=linux –enable-gpl –enable-omx –enab
    le-omx-rpi –enable-nonfree –enable-libfreetype –extra-libs=-lasound –enable-

    As pointed out by Teo Ruscin, If you don’t have lasound please do the following
    sudo apt-get -y install libasound2-dev

    Above tested with Raspberry Pi B (1st gen) with a Logitech C920.

    The best I managed to get is a 480p stream @ 2000kbps to Youtube. Still figuring out the audio section as aplay -L doesn’t list the C920 Audio device.

    Building FFMPEG takes almost 7-8hrs. I’m getting a RPi3 soon, so will rebuild it on the new setup and report back.


  • can you tell me how much space ffmpeg will occupy on pi memory card ?

  • It worked flawlessly on my RPi 2! Thank you for the excellent guide! :-)

  • Hello Hannes, I’ve just run successfully the installation on a RPi3 with newest Raspbian.
    It works like a charm! :)
    Thanks for the script & have a nice time!

  • Jonathan - 2017-07-22 00:52

    Hope somebody can help
    i keep getting this error :
    “/usr/local/lib/libavcodec.a(libx264.o): In function `X264_init’:
    /home/pi/src/FFmpeg/libavcodec/libx264.c:814: undefined reference to `x264_encoder_open_148′
    collect2: error: ld returned 1 exit status
    Makefile:202: recipe for target ‘x264’ failed
    make: *** [x264] Error 1 “

  • Why you are disabling opencl. Isn’t it nice to use gpu for ffmpeg?

    • I don’t remember but I would think that the Raspberry GPU has no OpenCL support.

Leave a Reply

Your email address will not be published.

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