How to Compile FFmpeg with VapourSynth Support

Compiling FFmpeg with VapourSynth support allows you to import and process VapourSynth video processing scripts directly inside FFmpeg without the need for intermediate files. This guide provides a step-by-step walkthrough on how to install the necessary dependencies, configure the FFmpeg build options with the --enable-vapoursynth flag, and compile the binaries on a Linux-based system.

Step 1: Install Required Dependencies

Before compiling FFmpeg, you must install the build tools, Python, and the VapourSynth development libraries. Run the following commands to install these on Ubuntu or Debian-based systems:

sudo apt update
sudo apt install -y build-essential yasm nasm pkg-config git python3-dev

Next, install VapourSynth and its development headers. You can install it via a PPA or compile it from source. For most users, using the PPA is the easiest method:

sudo add-apt-repository ppa:djcj/vapoursynth
sudo apt update
sudo apt install -y libvapoursynth-dev vapoursynth-extra-plugins

Ensure that pkg-config can locate the VapourSynth configuration files by running:

pkg-config --modversion vapoursynth
pkg-config --modversion vapoursynth-script

If these commands return version numbers, you are ready to proceed.

Step 2: Clone the FFmpeg Source Code

Clone the official FFmpeg Git repository and navigate into the source directory:

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg

Step 3: Configure the Build

Run the configure script with the --enable-vapoursynth flag. You should also enable GPL compatibility and any external codecs (like x264 or x265) you plan to use:

./configure \
  --enable-gpl \
  --enable-version3 \
  --enable-vapoursynth \
  --enable-libx264 \
  --enable-nonfree

Note: If the configuration fails, check the ffbuild/config.log file to ensure that Python and VapourSynth header paths are correctly recognized.

Step 4: Compile and Install

Once the configuration step completes without errors, compile the source code using all available CPU cores, then install the binaries to your system:

make -j$(nproc)
sudo make install

Step 5: Verify the Installation

To confirm that FFmpeg was compiled correctly with VapourSynth support, check the configuration flags:

ffmpeg -version | grep vapoursynth

You can also verify that the VapourSynth demuxer is successfully registered:

ffmpeg -demuxers | grep vapoursynth

If vapoursynth appears in the output, you can now feed .vpy scripts directly into FFmpeg using standard commands, such as ffmpeg -i input.vpy output.mp4.