Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installs ffmpeg with libaom and libx265 enabled for av1 and hevc encoding (tested on Ubuntu 16.04)
#!/usr/bin/env bash
# Installs ffmpeg from source (HEAD) with libaom and libx265, as well as a few
# other common libraries
# binary will be at ~/bin/ffmpeg
sudo apt update && sudo apt upgrade -y
mkdir -p ~/ffmpeg_sources ~/bin
export PATH="$HOME/bin:$PATH"
sudo apt -y install \
autoconf \
automake \
build-essential \
cmake \
git \
libass-dev \
libfreetype6-dev \
libsdl2-dev \
libtheora-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
mercurial \
pkg-config \
texinfo \
wget \
zlib1g-dev \
yasm \
libvpx-dev \
libopus-dev \
libx264-dev \
libmp3lame-dev \
libfdk-aac-dev
# Install libaom from source.
mkdir -p ~/ffmpeg_sources/libaom && \
cd ~/ffmpeg_sources/libaom && \
git clone https://aomedia.googlesource.com/aom && \
cmake ./aom && \
make && \
sudo make install
# Install libx265 from source.
cd ~/ffmpeg_sources && \
hg clone https://bitbucket.org/multicoreware/x265 && \
cd x265/build/linux && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source && \
make && \
make install
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 && \
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-libass \
--enable-libfdk-aac \
--enable-libmp3lame \
--enable-libx264 \
--enable-libx265 \
--enable-libtheora \
--enable-libfreetype \
--enable-libvorbis \
--enable-libopus \
--enable-libvpx \
--enable-libaom \
--enable-nonfree && \
make && \
make install && \
hash -r
@zdzislaw-paluch

This comment has been minimized.

Copy link

commented Jun 14, 2018

fetching https://aomedia.googlesource.com/aom (line 44) gives tls error (and does not downloading files - my Wget is 1.17.1 and microsoft version of ubuntu 4.4.0-17134-Microsoft x64 ) - changing protocol to http:// solves that problem

@namdvt

This comment has been minimized.

Copy link

commented Sep 22, 2018

How can I build x265 which supports 10 bit and HDR10 plus ? I tried to add -DENABLE_HDR10_PLUS='TRUE' and -DHIGH_BIT_DEPTH='TRUE' but it didn't work.

@Cascador

This comment has been minimized.

Copy link

commented Nov 18, 2018

sudo apt -y install => sudo apt install -y

Tcho !

@kslimani

This comment has been minimized.

Copy link

commented Nov 27, 2018

--extra-libs="-lpthread -lm" has made my day, thank you !

@LukeRoss00

This comment has been minimized.

Copy link

commented Apr 10, 2019

How can I build x265 which supports 10 bit and HDR10 plus ? I tried to add -DENABLE_HDR10_PLUS='TRUE' and -DHIGH_BIT_DEPTH='TRUE' but it didn't work

I believe that the correct option to pass to cmake is "-DHIGH_BIT_DEPTH:bool=on" or simply "-DHIGH_BIT_DEPTH=ON". But even more importantly, nasm must be installed before launching cmake (a step which is missing from this gist), otherwise x265 will be built without any assembler optimizations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.