#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Centos
# Inspired from https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
STEP=$1
# Get the dependencies:
if [ $STEP -eq 1 ];then
sudo yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir /tmp/ffmpeg_sources
# Install libmp3lame
cd /tmp/ffmpeg_sources
curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xzvf lame-3.100.tar.gz
cd lame-3.100
./configure --prefix="/usr/local/libexec/ffmpeg_build" --bindir="/usr/local/bin" --disable-shared --enable-nasm
make
make install
make distclean
fi
if [ $STEP -eq 2 ];then
cd /tmp/ffmpeg_sources
#git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
#git clone --depth 1 --branch tags/v2.0.0 https://github.com/mstorsjo/fdk-aac.git
wget https://github.com/mstorsjo/fdk-aac/archive/v2.0.0.tar.gz
tar xzf v2.0.0.tar.gz
#cd fdk-aac
cd fdk-aac-2.0.0
autoreconf -fiv
./configure --prefix="/usr/local/libexec/ffmpeg_build" --disable-shared
make
make install
fi
if [ $STEP -eq 3 ];then
# Install ffmpeg
cd /tmp/ffmpeg_sources
#git clone --depth 1 git://source.ffmpeg.org/ffmpeg
git clone --depth 1 --branch release/3.4 https://git.videolan.org/git/ffmpeg.git
cd ffmpeg
PKG_CONFIG_PATH="/usr/local/libexec/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="/usr/local/libexec/ffmpeg_build" \
--extra-cflags="-I/usr/local/libexec/ffmpeg_build/include" \
--extra-ldflags="-L/usr/local/libexec/ffmpeg_build/lib" \
--bindir="/usr/local/bin" \
--enable-libass \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libtheora \
--enable-libfdk-aac \
--enable-nonfree \
--enable-libvorbis
make
#make install
#make distclean
hash -r
fi