How to Compile FFmpeg with libwebp Support
This guide provides a straightforward, step-by-step walkthrough on
how to compile FFmpeg from source with support for the
libwebp library. By enabling WebP support in FFmpeg, you
can encode videos and images into Google’s highly efficient WebP format.
This article covers installing the necessary dependencies, acquiring the
source code, configuring the build, and verifying the final
installation.
Step 1: Install Required Dependencies
Before compiling FFmpeg, you must install the build tools and the WebP development libraries. Run the appropriate command for your operating system:
For Ubuntu/Debian:
sudo apt update
sudo apt install -y build-essential yasm pkg-config libwebp-dev gitFor CentOS/RHEL/Fedora:
sudo dnf groupinstall "Development Tools"
sudo dnf install -y yasm pkgconfig libwebp-devel gitFor macOS (using Homebrew):
brew install yasm pkg-config webp gitStep 2: Download the FFmpeg Source Code
Clone the official FFmpeg Git repository to your local machine:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpegAlternatively, you can download a specific stable release from the official FFmpeg website and extract it.
Step 3: Configure the Build
To compile FFmpeg with WebP support, you must pass the
--enable-libwebp flag to the configure script. It is also
recommended to enable GPL-licensed components, as many standard
workflows rely on them.
Run the configuration script:
./configure --enable-gpl --enable-libwebpNote: If you want a static build or need to install to a custom
directory, you can append flags like --prefix=/usr/local or
--disable-shared --enable-static.
Step 4: Compile and Install FFmpeg
Once the configuration process finishes without errors, compile the binaries using all available CPU cores:
make -j$(nproc)(On macOS, use make -j$(sysctl -n hw.ncpu)
instead).
After the compilation successfully completes, install the binaries to your system:
sudo make installStep 5: Verify libwebp Support
Verify that FFmpeg has been successfully compiled with the WebP encoder and decoder by running:
ffmpeg -codecs | grep webpYou should see output indicating both the WebP decoder and encoder are active:
DEV--- webp WebP (encoders: libwebp )
You can now use FFmpeg to convert images and videos to the WebP format. For example, to convert a single frame to WebP:
ffmpeg -i input.png -vcodec libwebp output.webp