|Version 7 (modified by 3 years ago) ( diff ),|
There are a few ways to get FFmpeg on macOS:
- Use a package manager like Homebrew or MacPorts to install
ffmpeg. These will automatically keep your FFmpeg installation up-to-date. See the Homebrew section below for more info.
- Download a static build for macOS. This is as easy as extracting and running the downloaded binary. One disadvantage with static builds is that updates have to be performed manually. Also, they may not contain all encoders or filters you want.
- Build it yourself. Compiling on macOS is as easy as on any other *nix machine. Download the source, then run
./configurewith the needed flags,
make install. However, the configuration options have to be set manually, and you will need to install third-party libraries yourself. See the compilation section below for more info.
ffmpeg through Homebrew
Homebrew is a command-line package manager, which is similar to
apt-get on popular Linux distributions. In order to use it, you need to install
brew first, if you haven't already:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Follow the on-screen instructions. This will take a few minutes while it's installing the necessary developer tools for macOS. Then, run:
brew install ffmpeg
to get the latest released version with minimal configuration (and library dependency) options. These versions are packaged as Homebrew formulas and will take care of all the dependencies and the installation itself.
Specifying additional options
You can run
brew info ffmpeg to see additional install options, e.g. in order to enable
libvpx, which are highly recommended. Here is an example with some additional options:
brew install ffmpeg \ --with-tools \ --with-fdk-aac \ --with-freetype \ --with-fontconfig \ --with-libass \ --with-libvorbis \ --with-libvpx \ --with-opus \ --with-x265
To later upgrade your
ffmpeg version to the latest released, simply run:
brew update && brew upgrade ffmpeg
If you want to install the latest Git version of
ffmpeg instead of the release version, follow the above directions, but add a --HEAD to the install command. For example:
brew install ffmpeg --with-tools --with-fdk-aac --with-libvpx --with-x265 --HEAD
Compiling FFmpeg yourself
Xcode is required to compile software on your Mac. Install Xcode by downloading it from the website or using the Mac App Store.
After installing Xcode, install the Command Line Tools from Preferences > Downloads > Components. You can also install the tools via your shell:
Installing dependencies with Homebrew
To get some dependencies for ffmpeg, you can install Homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install automake fdk-aac git lame libass libtool libvorbis libvpx \ opus sdl shtool texi2html theora wget x264 x265 xvid nasm
Manual install of the dependencies without Homebrew
Pkg-config & GLib
Pkg-config is necessary for detecting some of the libraries you can compile into FFmpeg, and it requires GLib, which is not included in macOS (but almost every other *nix distribution). You may either download pkg-config 0.23, or download the large tarball from Gnome.org and compile it. Pkg-config is available from Freedesktop.org.
To compile GLib, you must also download
gettext from GNU.org and edit the file
stpncpy.c to add
#undef stpncpy just before
#ifndef weak_alias. Mac OS X Lion has its own (incompatible) version of the
stpncpy function, which overlaps in
gettext as usual. Compile GLib with
LIBFFI_CFLAGS=-I/usr/include/ffi LIBFFI_LIBS=-lffi ./configure;make && sudo make install
To compile pkg-config, run
GLIB_CFLAGS="-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" GLIB_LIBS="-lglib-2.0 -lgio-2.0" ./configure --with-pc-path="/usr/X11/lib/pkgconfig:/usr/X11/share/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig"
Nasm is an assembler required for x264. The latest version is available at nasm.us.
These are just some examples. Run
./configure --help for all available options.
- x264 encodes H.264 video. Use
- fdk-aac encodes AAC audio. Use
- libvpx is a VP8 and VP9 encoder. Use
- libvorbis encodes Vorbis audio . Requires libogg. Use
- libopus encodes Opus audio.
- LAME encodes MP3 audio. Use
- libass is a subtitle renderer. Use
macOS already comes with freetype installed (older versions may need X11 selected during installation), but in an atypical location:
freetype-config in Terminal can give the locations of the individual folders, like headers, and libraries, so be prepared to add lines like
CFLAGS=`freetype-config --cflags` LDFLAGS=`freetype-config --libs` PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/opt/X11/lib/pkgconfig
Once you have compiled all of the codecs/libraries you want, you can now download the FFmpeg source either with Git or the from release tarball links on the website.
For general instructions on how to compile software, consult the Generic compilation guide. The information there is applicable to the macOS environment as well.
./configure --help, and study its output to learn what options are available. Make sure you've enabled all the features you want. Note that
--enable-gpl will be necessary for some of the dependencies above.
A sample compilation command is:
git clone http://source.ffmpeg.org/git/ffmpeg.git ffmpeg cd ffmpeg ./configure --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass \ --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \ --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid \ --samples=fate-suite/ make
After successful compilation, running
sudo make install will install the ffmpeg binaries with superuser rights. You can also set a prefix during configuration, e.g.
--prefix="$HOME/bin, where no root rights are needed for