building ffmpeg with vmaf support

A few reference links: - -

This is building on linux & wsl. I am running on Ubuntu 20.04 in both cases.

First, ensure various tools are updated and ensure that you have build-essentials installed. Install python3 and pip3 for Cython and numpy.

I have installed meson myself rather than going thru pip3, somehow system was not able to find it where it was install during building libvmaf. It shouldn’t matter which way you install as long as it is found during build.

sudo apt update
sudo apt install python3 python3-pip python3-setuptools python3-wheel ninja-build nasm
sudo apt install meson
sudo apt install zip unzip

Next, I downloaded latest vmaf from github repo and extracted in a directory, say ~\source\vmaf.

get vmaf from github repo (wget
extract it locally to a directory

To build and make & install vmaf:

cd vmaf
sudo make
sudo make install

// it is installed in location /usr/local/lib/x86_64-linux-gnu

Once, libvmaf is built and installed, it is now time to build ffmpeg and it will include the libvmaf.a file generated earlier.

First get all dependencies built and installed, we are going to various encoders and their dev-packages to be linked in ffmpeg:

sudo apt -y install autoconf automake build-essential cmake git-core
sudo apt -y install libass-dev libfreetype6-dev libgnutls28-dev libsdl2-dev 
sudo apt -y install libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev 
sudo apt -y install libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build 
sudo apt -y install pkg-config texinfo wget yasm zlib1g-dev nasm

sudo apt -y install libx264-dev libx265-dev libnuma-dev libopus-dev
sudo apt -y install libvpx-dev libfdk-aac-dev libmp3lame-dev

Next, create couple of directories in to extract source and build:

mkdir -p ~/ffmpeg_sources ~/bin

Now to build ffmpeg with various support encoders and filters execute below command. It will configure our build and list various filters and encoders it is going to build with:

cd ~/ffmpeg_sources
wget -O ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg

./configure --prefix="$HOME/ffmpeg_build"  --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib"   --extra-libs="-lpthread -lm" --ld="g++" --bindir="$HOME/bin"  --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus  --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265  --enable-libvmaf  --enable-nonfree

It prints a ton of stuff on terminal:

install prefix            /home/sarang/ffmpeg_build
source path               .
C compiler                gcc
C library                 glibc
ARCH                      x86 (generic)
big-endian                no
runtime cpu detection     yes
standalone assembly       yes
x86 assembler             nasm
MMX enabled               yes
MMXEXT enabled            yes
3DNow! enabled            yes
3DNow! extended enabled   yes
SSE enabled               yes
SSSE3 enabled             yes
AESNI enabled             yes
AVX enabled               yes
AVX2 enabled              yes
makeinfo supports HTML    yes

External libraries:

External libraries providing hardware acceleration:

avcodec                 avfilter                avutil                  swresample
avdevice                avformat                postproc                swscale

ffmpeg                  ffplay                  ffprobe

Enabled decoders:
aac                     bmp                     iac                     pcm_f24le               stl

Enabled encoders:
a64multi                dnxhd                   magicyuv                pcm_s64be               speedhq

Enabled hwaccels:

Enabled parsers:

Enabled demuxers:

Enabled muxers:

Enabled protocols:

Enabled filters:

Enabled bsfs:

Enabled indevs:

Enabled outdevs:

License: nonfree and unredistributable

To continue with build and installation, this will take a bit but it will build and install in local user’s directory:

make -j4
make install
hash -r

For me, it installed it in directory: /home/sarangb/bin/ffmpeg. Now, it gets fancy if you had installed ffmpeg thru apt install command earlier. In such case sourcing the ~/.profile helped with command source ~/.profile

Checking with the newly built ffmpeg, I can see that it has libvmaf support. Of course it is a non distributable build for my local consumption.

ffmpeg version N-101868-g557953a Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --prefix=/home/sarangb/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/sarangb/ffmpeg_build/include --extra-ldflags=-L/home/sarangb/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/sarangb/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libvmaf --enable-nonfree
  libavutil      56. 72.100 / 56. 72.100
  libavcodec     58.135.100 / 58.135.100
  libavformat    58. 78.100 / 58. 78.100
  libavdevice    58. 14.100 / 58. 14.100
  libavfilter     7.111.100 /  7.111.100
  libswscale      5. 10.100 /  5. 10.100
  libswresample   3. 10.100 /  3. 10.100
  libpostproc    55. 10.100 / 55. 10.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Now all of above was due to non availability of linux ffmpeg build with vmaf support. On windows, I found that builds from include vmaf support and didn’t had to jump thru hoops on windows..