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
- INSTALL H264 SUPPORT
Run the following commands, one at a time.
git clone git://git.videolan.org/x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
sudo make install
- INSTALL OTHER LIBRARIES/FORMATS
Anything else you would like to install should be done now, before compiling FFMPEG. This includes MP3, AAC, etc.
- INSTALL FFMPEG
Add lines similar to the
--enable-libx264 for anything else installed above. This may take a REALLY long time, so be patient.
git clone https://github.com/FFmpeg/FFmpeg.git
sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
sudo make install
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
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!
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 ]
Further experiment with Voronoi Diagrams, Processing, ffmpeg, and video (Max/MPS-ers may recognize the classic bball.mov source file).
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:
- Install Git
- Download LAME
- Download ffmpeg
- Find or create folder to install to
- Install LAME
- Install ffmpeg
Continue reading “Installing ffmpeg (and LAME) on Mac Snow Leopard and Lion”