Compile FFmpeg with libvpx on macOS
This guide provides a straightforward, step-by-step walkthrough on
how to compile FFmpeg from source with libvpx support on
macOS. By building FFmpeg manually, you can enable custom configurations
and native VP8/VP9 video encoding capabilities on both Intel and Apple
Silicon Macs.
Step 1: Install Xcode Command Line Tools
You need a C compiler and build tools. Open your Terminal and run the following command to install the Xcode Command Line Tools:
xcode-select --installStep 2: Install Dependencies via Homebrew
Compilation requires build tools like nasm,
yasm, and pkg-config, as well as the
libvpx library itself. The easiest way to install these is
using Homebrew.
If you do not have Homebrew installed, install it first, then run:
brew install git yasm nasm pkg-config libvpxStep 3: Clone the FFmpeg Source Code
Clone the official FFmpeg git repository to your local machine and navigate into the directory:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpegStep 4: Configure the Build
Before compiling, you must configure the build environment. The compile process needs to know where to find the Homebrew-installed libraries.
Run the configure script with the --enable-libvpx and
--enable-gpl flags.
For Apple Silicon (M1/M2/M3) Macs:
./configure --prefix=/usr/local --enable-gpl --enable-libvpx --extra-cflags="-I/opt/homebrew/include" --extra-ldflags="-L/opt/homebrew/lib"For Intel Macs:
./configure --prefix=/usr/local --enable-gpl --enable-libvpx --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib"Note: You can add other flags here if you require additional
libraries (e.g., --enable-libx264 for H.264
support).
Step 5: Compile and Install FFmpeg
Once configuration completes without errors, compile the binary using all available CPU cores to speed up the process, then install it:
make -j$(sysctl -n hw.ncpu)
sudo make installStep 6: Verify the Installation
Verify that FFmpeg has been installed correctly and that it includes
libvpx support by checking the version and enabled
configurations:
ffmpeg -versionLook for --enable-libvpx in the configuration output.
You can also verify that the VP8 and VP9 encoders are available by
running:
ffmpeg -encoders | grep vpx