Installing FFMPEG for Raspberry Pi

ffmpegOnRaspberryPi-web

FFMPEG is one of those tools I use when I just want to quickly hack together a video and don’t need fancy things like editing, titles, or a user-interface. Compiling on a regular computer isn’t easy, but compiling for the Raspberry Pi takes a little more patience and care. I also wanted to include support for H264 video, which needs to be installed before compiling FFMPEG.

There are lots of examples on the web, but what worked for me was a combination of a few of them, so here’s what I did. Note many of these commands may require  sudo appended before (commands like git , ./configure, and make )

  1. INSTALL H264 SUPPORT
    Run the following commands, one at a time.
  2. INSTALL OTHER LIBRARIES/FORMATS
    Anything else you would like to install should be done now, before compiling FFMPEG. This includes MP3, AAC, etc.
  3. INSTALL FFMPEG
    Add lines similar to the  --enable-libx264  for anything else installed above. This may take a REALLY long time, so be patient.

    As Malcshour notes, if you have a Model B+ you can use make -j4  instead of just make  to take advantage of all four cores!

    DONE! TEST IT
    To test your new install, simply run the command ffmpeg . If you don’t get any errors, you’re all good. What did I do with my new tool? I built a bot that generates random guitar chords.

A FEW MORE RESOURCES

Did you find this post helpful or interesting? A small donation goes a long way towards helping produce this content. If you can't, please share what you've done with others!
Donate via Flattr

58 Replies to “Installing FFMPEG for Raspberry Pi”

  1. I get the below error when i run make for ffmpeg

    libavfilter/libavfilter.a(allfilters.o): In function avfilter_register_all':
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_paletteuse’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_perspective'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_phase’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_pixdesctest'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_pp’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_pp7'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_premultiply’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_psnr'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_pullup’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_qp'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_random’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_readeia608'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_readvitc’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_remap'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_removegrain’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_removelogo'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_repeatfields’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_rotate'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_sab’
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to ff_vf_scale'
    /home/pi/Documents/digital_factory/FFmpeg/libavfilter/allfilters.c:381: undefined reference to
    ff_vf_scale2ref’
    collect2: error: ld returned 1 exit status
    Makefile:131: recipe for target ‘ffmpeg_g’ failed
    make: *** [ffmpeg_g] Error 1

  2. At Point 3 it gives me an error because the ffmepg dir is in capital letters.

    It should be:

    cd /usr/src
    git clone https://github.com/FFmpeg/FFmpeg.git
    cd FFmpeg
    sudo ./configure –arch=armel –target-os=linux –enable-gpl –enable-libx264 –enable-nonfree
    make
    sudo make install

  3. Hi,
    I have used these commands on RPi 3 and it worked fine.
    Now, If I want to “copy” the ffmpeg installation to another RPi3, what files should I copy so that I dont have to build the whole thing again on the new RPi3?

  4. While “sudo make” fpr ffmpeg via SSH I got the following error
    packet_write_wait: Connection to 192.168.0.35 port 22: Broken pipe
    Is there a way to resume the session? Or is the “making” continuing when the session breaks?

    CC libavcodec/vp9block.o
    CC libavcodec/vp9data.o
    CC libavcodec/vp9dsp.o
    CC libavcodec/vp9dsp_10bpp.o

    these were the last lines before it broke?
    Should I just wait a few hours and the continue with sudo make install?

  5. @HansWurst – I don’t think there’s a way to resume an SSH session that breaks like that. I think you’ll have to start over. For this install, probably better to do it locally, if possible, since it can take a really (really) long time.

  6. yeah, I realized that. So you don’t know if it continues when the session breaks? I might just try to sudo make install tomorrow in the morning. If it continued it should be done by then…

Leave a Reply

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