February 15, 2016

Compiling ffmpeg on OSX

ffpmeg

Compiling ffmpeg on OSX is fairly straightforward except for a few prerequisites and configuration options. The instructions below will build ffmpeg using the configuration of the semi-official OSX distro at evermeet.cx/ffmpeg/ with the exception that –enable-libvo-amrwbenc and –enable-libxavs are exluded. (I didn’t include them because they do not have brew formulas. They could most likely be compiled from source as well but for my purposes I don’t need them anyway).

First install the prerequisite tools and libraries. This assumes you have homebrew installed:

brew install automake fdk-aac git lame libass libtool libvorbis libvpx \
opus sdl shtool texi2html theora wget x264 xvid yasm \
libmodplug libbluray libgsm opencore-amr schroedinger snappy libsoxr \
speex libvidstab wavpack x265 zmq

After the pre-reqs are installed, download the latest ffmpeg source, unzip and CD to that directory. Run the following configuration. (note the extra-cflags and extra-ldflags, these are the magic arguments that allow configure to locate all of the libraries installed in the first step)

./configure --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib \
--as=yasm \
--extra-version=tessus \
--enable-avisynth \
--enable-fontconfig \
--enable-gpl \
--enable-libass \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopus \
--enable-libbluray \
--enable-libgsm \
--enable-libmodplug \
--enable-libschroedinger \
--enable-libsnappy \
--enable-libsoxr \
--enable-libspeex \
--enable-libtheora \
--enable-libvidstab \
--enable-libvorbis \
--enable-libvpx \
--enable-libwavpack \
--enable-libx264 \
--enable-libx265 \
--enable-libxvid \
--enable-libzmq \
--enable-version3 \
--disable-ffplay \
--disable-indev=qtkit \
--disable-indev=x11grab_xcb

Finally build as normal:

make

There may be some warnings in the compile output which are safe to ignore. Assuming there were no errors, you should now have an ffmpeg binary in the current directory.

Note ffmpeg/libavformat/tls_securetransport.c makes calls to private OSX APIs and has to be dealt with for distribution in the MAS.

Leave a Reply

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