How to Compile FFmpeg with zscale
Compiling FFmpeg with the zscale filter allows you to
utilize the high-quality zimg library for advanced image
scaling, colorspace conversion, and HDR-to-SDR tone mapping. This
step-by-step guide will walk you through installing the necessary
dependencies, compiling the zimg library from source, and
configuring FFmpeg with the --enable-libzimg flag to
activate the zscale filter.
Step 1: Install Build Dependencies
Before compiling, you need to install the essential build tools and libraries. Run the following command on Debian/Ubuntu-based systems:
sudo apt update
sudo apt install -y build-essential git autoconf automake libtool pkg-configStep 2: Compile and Install the zimg Library
The zscale filter in FFmpeg is a wrapper for the
zimg library. You must compile and install
zimg from its official source repository.
Clone the
zimgrepository:git clone --recursive https://github.com/sekrit-twc/zimg.git cd zimgGenerate the configuration scripts:
./autogen.shConfigure, build, and install the library:
./configure make -j$(nproc) sudo make installUpdate the shared library cache so your system recognizes the newly installed library:
sudo ldconfig
Step 3: Download and Compile FFmpeg
With zimg installed, you can now configure and compile
FFmpeg.
Clone the FFmpeg source code:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg cd ffmpegRun the configure script. You must include the
--enable-libzimgflag. It is also recommended to enable GPL support via--enable-gpl:./configure --enable-gpl --enable-libzimgCompile FFmpeg using all available CPU cores:
make -j$(nproc)Install the compiled FFmpeg binary to your system:
sudo make install
Step 4: Verify the Installation
To ensure that FFmpeg was compiled correctly and that the
zscale filter is available, run the following command:
ffmpeg -filters | grep zscaleIf the compilation was successful, the output will display the
zscale filter details:
... zscale V->V Apply resize, colorspace, and depth conversion.