Skip to content

Instantly share code, notes, and snippets.

@ocdude
Last active July 5, 2019 20:25
Show Gist options
  • Save ocdude/fe924f0c118274b65648 to your computer and use it in GitHub Desktop.
Save ocdude/fe924f0c118274b65648 to your computer and use it in GitHub Desktop.
ffmpeg configure parameters
#!/bin/bash
# This script will download all of the appropriate and necessary components required to
# install FFMPEG on Ubuntu 14.04 and above. This uses checkinstall instead of the normal
# make install to generate a .deb so ffmpeg and the x265 library can be managed by the package manager.
# When passed the nvenc parameter, it will attempt to compile ffmpeg with the nvenc and nvenc_h265 encoders which use
# nvidia GPUs for encoding rather than CPU. Check https://developer.nvidia.com/nvidia-video-codec-sdk for more information.
set -e
DIR="$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORK_DIR=`mktemp -d -p "$DIR"`
function cleanup {
sudo rm -rf "$WORK_DIR"
echo "Deleted temp working directory $WORK_DIR"
}
trap cleanup EXIT
echo "Getting required libraries and tools..."
# download and install libraries from ubuntu's repository where possible
sudo apt-get update
sudo apt-get install checkinstall autoconf automake git build-essential yasm cmake cmake-curses-gui mercurial \
libass-dev libx264-dev libfdk-aac-dev libmp3lame-dev libopus-dev libvpx-dev libfreetype6-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev unzip wget sysstat nasm libnuma-dev
# grab libx265 HVEC encoder from source
cd "$WORK_DIR"
echo "Fetching libx265 source..."
hg clone https://bitbucket.org/multicoreware/x265
cd x265/build/linux
cmake "$WORK_DIR/x265/source"
make
sudo make install
make clean
echo "Fetching libom..."
cd "$WORK_DIR"
git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom
mkdir aom_build
cd aom_build
cmake ../aom
make
sudo make install
# reload shared libraries to make sure libx265 is visible to ffmpeg later
sudo ldconfig
cd ../../../
# Grab latest ffmpeg from source
echo "Fetching ffmpeg source..."
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git ffmpeg
if [ "$1" = "nvenc" ]; then
# download required nvidia sdk
wget https://developer.nvidia.com/video-sdk-601
unzip video-sdk-601
sudo cp nvidia_video_sdk_6.0.1/Samples/common/inc/*.h /usr/local/include
# configure with added nvidia goodies
cd ffmpeg
./configure \
--enable-pthreads \
--enable-avresample \
--enable-gpl \
--enable-nonfree \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-version3 \
--enable-nvenc
else
cd ffmpeg
# Configure ffmpeg with libass, freetype, theora, vorbis, vp8/9, h264, h265, libaom, and jpeg2000 support
# Also enable multi-threading
./configure \
--enable-pthreads \
--enable-avresample \
--enable-gpl \
--enable-nonfree \
--enable-libass \
--enable-libfreetype \
--enable-libfontconfig \
--enable-libfribidi \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-libaom \
--enable-version3
fi
make -j 4
# prepend RELEASE version
sudo checkinstall --pkgname="ffmpeg" --provides="ffmpeg,ffplay,ffserver,ffprobe" --pkgversion="$(cat RELEASE)" -D -y
sudo ldconfig
make distclean
echo "FFMPEG has been installed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment