Skip to content

Instantly share code, notes, and snippets.

@peerasan
Last active February 2, 2024 23:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save peerasan/8ee6df7df6ed764c606f99d245e74211 to your computer and use it in GitHub Desktop.
Save peerasan/8ee6df7df6ed764c606f99d245e74211 to your computer and use it in GitHub Desktop.
Build FFmpeg
# Watch video: https://youtu.be/qLw6ZWUXy7U
#Require for Compiler
apt-get install -y autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev
#Require for FFmpeg
apt-get install nasm libx264-dev libx265-dev libnuma-dev libvpx-dev libfdk-aac-dev libmp3lame-dev libopus-dev libunistring-dev
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
#libaom
cd ~/ffmpeg_sources
git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom
mkdir -p aom_build
cd aom_build
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off -DENABLE_NASM=on ../aom
PATH="$HOME/bin:$PATH" make -j 8
make install
#libsvtav1
cd ~/ffmpeg_sources
git -C SVT-AV1 pull 2> /dev/null || git clone https://github.com/AOMediaCodec/SVT-AV1.git
mkdir -p SVT-AV1/build
cd SVT-AV1/build
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=OFF ..
PATH="$HOME/bin:$PATH" make -j 8
make install
#ffmpeg
cd ~/ffmpeg_sources
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./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" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-gnutls \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libsvtav1 \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
PATH="$HOME/bin:$PATH" make -j8
make install
@SalimF
Copy link

SalimF commented Aug 19, 2022

I tried the build and I got this error
ERROR: SvtAv1Enc >= 0.9.0 not found using pkg-config

BTW SvtAv1Enc is installed system wide in this location

/usr/local/lib64/pkgconfig/SvtAv1Dec.pc
/usr/local/lib64/pkgconfig/SvtAv1Enc.pc

=Edit= I solve it by add /usr/local/lib64/pkgconfig/ to the path

PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig:$HOME/ffmpeg_build/lib/pkgconfig:$HOME/lib64/pkgconfig" .

@STSOL
Copy link

STSOL commented Oct 31, 2022

In case of an error regarding makefiles for the libsvtav1.

  1. Remove the ffmpeg_sources folder
  2. The links for the libsvtav1 github should be changed to https://gitlab.com/AOMediaCodec/SVT-AV1.
  3. Rerun the script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment