Skip to content

Instantly share code, notes, and snippets.

@sentenza
Last active October 26, 2017 09:53
Show Gist options
  • Save sentenza/fe57620db01959bdd7da805c68749885 to your computer and use it in GitHub Desktop.
Save sentenza/fe57620db01959bdd7da805c68749885 to your computer and use it in GitHub Desktop.

Installing ffmpeg 3.4 and all the needed libraries

Dependencies

# From the official ffmpeg docs
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl1.2-dev libtheora-dev libtool libvorbis-dev pkg-config texinfo zlib1g-dev \
yasm libx264-dev libmp3lame-dev libvpx-dev libfdk-aac-dev

Nasm

NASM assembler. Required for compilation of x264 and other tools.

cd ~/ffmpeg_sources
wget http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.tar.bz2
tar xjvf nasm-2.13.01.tar.bz2
cd nasm-2.13.01
./autogen.sh
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
PATH="$HOME/bin:$PATH" make
make install

libx264 (H.264 video encoder)

Requires ffmpeg to be configured with --enable-gpl and --enable-libx264.

cd ~/ffmpeg_sources
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --disable-opencl
PATH="$HOME/bin:$PATH" make
make install

libx265

H.265/HEVC video encoder. Requires ffmpeg to be configured with --enable-libx265.

sudo apt-get install cmake mercurial
cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install

libfdk-aac

AAC audio encoder. Requires ffmpeg to be configured with --enable-libfdk-aac (and --enable-nonfree if you also included --enable-gpl).

sudo apt-get install libfdk-aac-dev

libopus

Opus is an audio decoder and encoder. Requires ffmpeg to be configured with --enable-libopus.

cd ~/ffmpeg_sources
wge https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz
tar xzvf tar xzvf opus-1.2.1.tar.gz
cd opus-1.2.1/
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install

VP8/VP9 libvpx

VP8/VP9 video encoder and decoder. Requires ffmpeg to be configured with --enable-libvpx.

ffmpeg 3.4

wget http://ffmpeg.org/releases/ffmpeg-3.4.tar.bz2
tar xjvf ffmpeg-3.4.tar.bz2
cd ffmpeg-3.4/
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 \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libtheora \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --enable-nonfree
 
PATH="$HOME/bin:$PATH" make
make install
hash -r

Create a .deb package

In order to create a debian package we can use checkinstall:

checkinstall -D --install=no

Install FFmpeg on Ubuntu Trusty

The fastest way to do it is to add the ubuntu-media PPA, install version 3.3, then remove it and install ours 3.4.

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg -y
sudo dpkg -r ffmpeg
sudo dpkg -i ffmpeg_3.4-2-1_amd64.deb

Resources

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