Usually i work with stable releases of FFmpeg as i feel more comfortable using it in stable state on a daily basis. Of course, for some bugfixes i were waiting for i switch to the nightly build until the next stable release comes out. Anyway, using a version of FFmpeg on OS X installed through Homebrew you have to stick with the latest implemented stable release on Homebrew. As recently FFmpeg 2.0 was released with some great new features i wanted to try it as soon as possible without compiling everything from scratch. For this, it came to my mind that i could use all the libraries of my Homebrew FFmpeg version and just compile it with a new core. And it was not that hard as it might sound.
If you have not installed FFmpeg yet using Homebrew, check out this article where i describe how to do it.
Get the compiler flags
Thanks to the FFmpeg.Developers it is really easy to get the configuration flags your current version is compiled with. Simply execute $ ffmpeg on your commandline and you will see something like this:
The most important for us now is this part:
These are our configuration flags we will use later.
Prepare your environment
Next we need to create a folder where our “special”-version of FFmpeg will live in. Later we will be able to have multiple versions of FFmpeg, isn’t that great? So, i decided to create a folder called ffmpeg-latest in /usr/local/ with
.
Get FFmpeg
Now we will go and get the latest FFmpeg from Git and download it to the /tmp folder as we will not not need it anymore after compiling.
So, first change the directory to /tmp with $ cd /tmp and get FFmpeg using
. If you have no git installed, you can install it using Homebrew with
and try it again. The complete source code should now be available in /tmp/ffmpeg.
Build your configure command
At least we have to complete the configure command so FFmpeg can find all libraries. We just need to modify the prefix-flag and add two extra flags to tell FFmpeg where to look for libs and includes. As we chosed /usr/local/ffmpeg-latest as our installation directory, this will also be the value for the prefix-flag.
On a default installation Homebrew will install the includes in /usr/local/Cellar/include and all libraries in /usr/local/Cellar/libs. If you have installed Homebrew on a different way or anything has changed meanwhile, you need to check where your libs/include-folders are. To have FFmpeg looking into those folders we have to add –extra-cflags=’-I/usr/local/Cellar/include’ and –extra-ldflags=’-L/usr/local/Cellar/lib’ to our configure command.
Putting it together:
Compile it
Now we can compile it. First change the directory to /tmp/ffmpeg with
. After that you’re ready to fire the configure command like this:
I assume this will work without any issues and you can go further to build your new ffmpeg version using
. This will take a few minutes so take a break and get a coffee ;).
If this has also finished without any errors ( warnings are quite normal here ) you can install it using
. After completition of this command your finally done.
You can now execute your new FFmpeg version using
.
Extra: Create a symlink
As i usually like to have my tools in the system path environment i’ll show how to create a symlink for your new FFmpeg version so the binary remains in /usr/local/ffmpeg-latest/bin but you don’t need to add the path into your system path which would also come to an error as you have another FFmpeg binary in your path. Anyway, i prefer to create a symlink in /usr/local and here’s how it’s been done:
From this time you can simply execute
to use the latest version.