ffmpeg on raspbian / Raspberry Pi

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.

33 thoughts on “ffmpeg on raspbian / Raspberry Pi

  1. anonymous

    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.

    Reply
  2. Lucas

    Hi!

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

    Reply
  3. Thomas

    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”

    Reply
      1. Hannes

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

        make -j4 should work though.

        Reply
  4. mcgyver83

    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.

    Reply
  5. Pingback: | 3D Printing – RepRap Snappy

  6. Pingback: | Live 3D Printing, Well Sort Off…

  7. Anonymous

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

    Reply
  8. norpos

    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

    Reply
  9. Francesco

    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

    Reply
  10. Marco

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

    Reply
  11. Teo Ruscin

    In order for alsa USB devices to work properly, compile with the following:
    –extra-libs=-lasound

    Reply
  12. Kevin

    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-
    libmp3lame

    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.

    Cheers.

    Reply
  13. Peter

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

    Reply
  14. Jonathan

    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 “

    Reply
  15. Pingback: #StackBounty: #audio #alsa #ffmpeg FFMPEG: Unknown input format: 'alsa' – TechUtils.in

    1. Hannes Post author

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

      Reply

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.