Skip to content

Instantly share code, notes, and snippets.

@thenadz
Last active January 14, 2022 13:46
Show Gist options
  • Save thenadz/c2791d74a9ec47e014a1 to your computer and use it in GitHub Desktop.
Save thenadz/c2791d74a9ec47e014a1 to your computer and use it in GitHub Desktop.
Downloads & builds headless FFMPEG along with all dependencies in parallel, enabling all features
#!/bin/bash -e
# Distro: Ubuntu 14.04.2 LTS
# Derived from https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
# Builds the dependencies in parallel prior to starting FFmpeg build.
sudo apt-get update
sudo apt-get -y --force-yes install \
autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev \
libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev yasm \
cmake mercurial unzip libx264-dev libmp3lame-dev libopus-dev libfdk-aac-dev
rm -rf ~/ffmpeg
mkdir -p ~/ffmpeg/sources
mkdir -p ~/ffmpeg/build
mkdir -p ~/bin
pushd ~/ffmpeg/sources
# libx265
{
hg clone --insecure https://bitbucket.org/multicoreware/x265
pushd 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
make distclean
} &
# libfdk-aac
{
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master
unzip fdk-aac.zip
pushd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg/build" --disable-shared
make
make install
make distclean
} &
# libvpx
{
wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
tar xjvf libvpx-v1.3.0.tar.bz2
pushd libvpx-v1.3.0
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg/build" --disable-examples --disable-unit-tests
PATH="$HOME/bin:$PATH" make
make install
make clean
} &
# ffmpeg download & extract
{
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
} &
# join all dependant jobs before starting ffmpeg
wait
# ffmpeg
pushd 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" \
--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
make distclean
hash -r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment