ffmpeg compilation script for Ubuntu

Ubuntu doesn’t provide the latest ffmpeg or include the modules I use all the time, so I wrote a little script to automatically compile and install my own version:


#!/bin/sh

# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

# SERVER COMPILATION SKIPS ffplay AND A X11 DEPENDENCIES

echo 'THIS SCRIPT USES SUDO, SO IT MIGHT ASK FOR YOUR PASSWORD'
sudo apt-get update -qq

sudo apt-get -y install \
	autoconf \
	automake \
	build-essential \
	cmake \
	git \
	libass-dev \
	libfreetype6-dev \
	libtheora-dev \
	libtool \
	libvorbis-dev \
	mercurial \
	pkg-config \
	texinfo \
	wget \
	zlib1g-dev \
	yasm \
	libx264-dev \
	libvpx-dev \
	libfdk-aac-dev \
	libmp3lame-dev \
	libopus-dev



cd ~/src

# DO WE NEED NASM?
# wget http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/nasm-2.13.02.tar.bz2
# tar xjvf nasm-2.13.02.tar.bz2
# pushd nasm-2.13.02
# ./autogen.sh
# PATH="$HOME/bin:$PATH" ./configure --prefix="/usr/local" --bindir="/usr/local/bin"
# make
# sudo make install


# DO WE NEED x265
if cd x265 2> /dev/null; then hg pull && hg update; else hg clone https://bitbucket.org/multicoreware/x265; fi
cd x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local/" -DENABLE_SHARED:bool=off ../../source
PATH="$HOME/bin:$PATH" make
sudo make install


# ACTUAL COMPILATION
cd ~/src
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="/usr/local/lib/pkgconfig" ./configure \
  --prefix="/usr/local" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I/usr/local/include" \
  --extra-ldflags="-L/usr/local/lib" \
  --extra-libs="-lpthread -lm" \
  --bindir="/usr/local/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

make
sudo make install
hash -r


About the Author

One thought on “ffmpeg compilation script for Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts