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

Creating Video With Processing and FFMPEG

Max/MSP users: look familiar?

For the past week I have been wrangling with getting ffmpeg (the open-source, command line video utility) to run in a Processing sketch and preserve the hard edges of graphical and/or intentionally pixelly video. It now works!

Details are listed in the code itself, but it is most important to note that the codec is likely the most important factor in getting good quality.   The “png” codec is great, but will create rather large files; mjpeg (MotionJPEG) also works well for graphics and hard edges (pixellated images, etc); H.264 is all-around good for photgraphic images.

The sketch below runs ffmpeg’s commands within Processing (as covered before) and exports a video from a series of still files.  Processing’s built-in video library seems ok, but offers little in the way of control as compared to ffmpeg.  Questions or suggestions are welcomed – feel free to use but please give credit!

UPDATE:
While I really don’t know why, the previous sketch seems to break with a Java IOException error.  It appears that ffmpeg can’t be found, but the solution is simple: specify the path to your ffmpeg install.  For example:

    /usr/local/bin/ffmpeg filename.mov etc...

The “-c:v” option to specify the codec is also updated to “-vcodec” and “-acodec”

[ download the updated sketch here ]

 

 

Voronoi Video

Further experiment with Voronoi Diagrams, Processing, ffmpeg, and video (Max/MPS-ers may recognize the classic bball.mov source file).

Installing ffmpeg (and LAME) on Mac Snow Leopard and Lion

A video still created programmatically; thousands of these can be combined into video using the ffmpeg library – faster and cleaner than a clunky Final Cut project

UPDATE 2: I ran into an error trying to install ffmpeg using these instructions yesterday.  However, installing using MacPorts worked like a charm! I suggest following the instructions for installing LAME first, then use MacPorts to install ffmpeg using the following command:

UPDATE: Having switched recently to Lion, the install below didn’t quite work.  With a small tweak, it appears to be ok – see below for details.

Well, it might not be Lion (doing live musical performance with my laptop makes me leary of new operating systems) but after finding little recent info on installing ffmpeg on a Mac, I’ve put together this basic outline.  For someone who isn’t great at installing libraries using Terminal, it wasn’t completely straightforward, but it works!  You will need the Apple Developer Tools to make this work (so far as I can tell).

UPDATE: I did a fresh install of XCode and had to do one small addition to get everything to compile.  For details, see this post.

This tutorial is based on the tutorial by Stephen Jungels, with some explanation and consolidation targeted at noobs (like myself).  Definite hat tip, Stephen!

The basic steps are as follows, full details after the break:

  1. Install Git
  2. Download LAME
  3. Download ffmpeg
  4. Find or create folder to install to
  5. Install LAME
  6. Install ffmpeg
  7. Test

Continue reading “Installing ffmpeg (and LAME) on Mac Snow Leopard and Lion”