Skip to content

Instantly share code, notes, and snippets.

@JohnPreston
Last active August 27, 2017 23:37
Show Gist options
  • Save JohnPreston/3315672bac02f635708aa3cd155537f3 to your computer and use it in GitHub Desktop.
Save JohnPreston/3315672bac02f635708aa3cd155537f3 to your computer and use it in GitHub Desktop.
Script to install FFPMpeg on Amazon Linux - Centos
#!/usr/bin/env bash
if ! [ "$#" -eq 1 ]; then
echo "Usage: install_ffmpeg_amzn_linux.sh build_directory"
exit 1
fi
CPU_THREADS=`cat /proc/cpuinfo | grep processor | tail -1 | awk '{print $NF}'`
ROOT_DIR=$1
SOURCES_DIR=$ROOT_DIR/ffmpeg_sources
BUILD_DIR=$ROOT_DIR/ffmpeg_build
BIN_DIR=$ROOT_DIR/ffmpeg/bin
yum install autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel yasm libxml2-devel -y
yum install fribidi-devel -y --enablerepo=epel
mkdir -p $SOURCES_DIR
mkdir -p $BUILD_DIR
mkdir -p $BIN_DIR
############################################
# x264 #
############################################
cd $SOURCES_DIR
git clone --depth 1 git://git.videolan.org/x264
cd x264
export PKG_CONFIG_PATH="$BUILD_DIR/lib/pkgconfig"
./configure --prefix="$BUILD_DIR" --bindir="$BIN_DIR" --enable-static
make -j $CPU_THREADS
make install
############################################
# MultiCoreWare #
############################################
cd $SOURCES_DIR
hg clone https://bitbucket.org/multicoreware/x265
cd $SOURCES_DIR/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$BUILD_DIR" -DENABLE_SHARED:bool=off ../../source
make -j $CPU_THREADS
make install
############################################
# MP3Lame #
############################################
cd $SOURCES_DIR
curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$BUILD_DIR" --bindir="$BIN_DIR" --disable-shared --enable-nasm
make -j $CPU_THREADS
make install
############################################
# LIBFAAC #
############################################
cd $SOURCES_DIR
wget http://sourceforge.net/projects/faac/files/faac-src/faac-1.28/faac-1.28.tar.bz2/download -O ffac.tar.bz2
tar -jxf ffac.tar.bz2
cd faac-1.28
#sed to remove the line 126 in common/mp4v2/mpeg4ip.h
sed -i '126,126d' common/mp4v2/mpeg4ip.h
./configure --prefix="$BUILD_DIR"
make -j $CPU_THREADS
make install
############################################
# LIBVPX #
############################################
cd $SOURCES_DIR
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
./configure --prefix="$BUILD_DIR" --disable-examples
make -j $CPU_THREADS
make install
############################################
# LIBVORBIS #
############################################
cd $SOURCES_DIR
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
tar xzvf libvorbis-1.3.4.tar.gz
cd libvorbis-1.3.4
./configure --prefix="$BUILD_DIR" --with-ogg="$BUILD_DIR" --disable-shared
make -j $CPU_THREADS
make install
############################################
# LIBOGG #
############################################
cd $SOURCES_DIR
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.gz
tar xzvf libogg-1.3.1.tar.gz
cd libogg-1.3.1
./configure --prefix="$BUILD_DIR" --disable-shared
make -j $CPU_THREADS
make install
############################################
# LIBTHEORA #
############################################
cd $SOURCES_DIR
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz
tar xzvf libtheora-1.1.1.tar.gz
cd libtheora-1.1.1
./configure --prefix="$BUILD_DIR" --with-ogg="$BUILD_DIR" --disable-examples --disable-shared --disable-sdltest --disable-vorbistest
make -j $CPU_THREADS
make install
############################################
# LIBFREETYPE #
############################################
cd $SOURCES_DIR
wget http://downloads.sourceforge.net/freetype/freetype-2.6.5.tar.bz2
tar xjf freetype-2.6.5.tar.bz2
cd freetype-2.6.5
./configure --prefix="$BUILD_DIR" --with-ogg="$BUILD_DIR" --disable-examples --disable-shared --disable-sdltest --disable-vorbistest
sed -ri "s:.*(AUX_MODULES.*valid):\1:" modules.cfg &&
sed -r "s:.*(#.*SUBPIXEL_(RENDERING|HINTING 2)) .*:\1:g" \
-i include/freetype/config/ftoption.h &&
./configure --prefix="$BUILD_DIR" --disable-static
make -j $CPU_THREADS
make install
############################################
# FONTCONFIG #
############################################
cd $SOURCES_DIR
wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.1.tar.bz2
tar xjf fontconfig-2.12.1.tar.bz2
cd fontconfig-2.12.1
./configure --prefix="$BUILD_DIR" --disable-docs --sysconfdir=/etc --enable-libxml2
make -j $CPU_THREADS
make install
############################################
# FFMPEG #
############################################
export LD_LIBRARY_PATH=/usr/local/lib/:$BUILD_DIR/lib
echo /usr/local/lib >> /etc/ld.so.conf.d/custom-libs.conf
echo /opt/ffmpeg_build/lib >> /etc/ld.so.conf.d/custom-libs.conf
ldconfig
cd $SOURCES_DIR
wget https://github.com/FFmpeg/FFmpeg/archive/n3.1.3.zip
unzip n3.1.3.zip
cd FFmpeg-n3.1.3/
export PKG_CONFIG_PATH="$BUILD_DIR/lib/pkgconfig"
./configure --prefix="$BUILD_DIR" \
--extra-cflags="-I$BUILD_DIR/include" \
--extra-ldflags="-L$BUILD_DIR/lib" \
--bindir="$BIN_DIR" \
--pkg-config-flags="--static" \
--extra-libs=-ldl \
--enable-version3 \
--enable-gpl \
--enable-libfaac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-nonfree \
--enable-libfribidi \
--enable-postproc \
--enable-pthreads \
--enable-libfontconfig
make -j $CPU_THREADS
make install
echo 'export PATH=$PATH:/opt/ffmpeg/bin' > /etc/profile.d/ffmpeg.sh
#rm -rfv $SOURCES_DIR/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment