|
#!/bin/bash
|
|
|
|
###############################################################################
|
|
# FFmpeg Build Script #
|
|
# #
|
|
# This script is based on instructions here: #
|
|
# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu #
|
|
# #
|
|
# NOTE: The script is designed to build shared libraries instead of static #
|
|
# ones as the original instructions did. #
|
|
# #
|
|
###############################################################################
|
|
|
|
# Helper function to pause between each step
|
|
function pause {
|
|
echo "Press any key to continue"
|
|
#~ read -n 1
|
|
echo
|
|
echo
|
|
}
|
|
|
|
# Use aggressive compiler flags (not sure these flags really matter these days...)
|
|
export CFLAGS="-O3 -march=native -mtune=native"
|
|
export CXXFLAGS=$CFLAGS
|
|
|
|
NUM_CORES=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
|
|
|
|
# Setup directories - modify as needed
|
|
DATESTAMP=$(date +%Y%m%d-%H%M%S)
|
|
SOURCES_DIR="/tmp/ffmpeg-${DATESTAMP}/"
|
|
INSTALL_DIR="/opt/local"
|
|
BIN_DIR="$INSTALL_DIR/bin"
|
|
|
|
|
|
# Set to a string containing the version you wish to install
|
|
FFMPEG_VERSION="8.0"
|
|
|
|
echo -e "BlackLynx FFmpeg Build Script\n"
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo -e "ERROR: This script must be run as root\n"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "Sources directory: ${SOURCES_DIR}"
|
|
echo -e "Install directory: ${INSTALL_DIR}"
|
|
echo -e "FFmpeg version: ${FFMPEG_VERSION}\n\n"
|
|
|
|
|
|
# Determine which OS the script is running on
|
|
DISTRIB_ID="$(lsb_release -is)"
|
|
|
|
# Install prereqs depending on OS version
|
|
if [[ "$DISTRIB_ID" == "RedHatEnterpriseServer" ||
|
|
"$DISTRIB_ID" == "CentOS" ]]; then
|
|
echo -e "\nRedHat/CentOS detected\n\n";
|
|
sudo yum -y install \
|
|
autoconf \
|
|
automake \
|
|
cmake3 \
|
|
git \
|
|
libass-devel \
|
|
freetype-devel \
|
|
libnuma \
|
|
SDL2-devel \
|
|
libtool \
|
|
libva-devel \
|
|
libvdpau-devel \
|
|
libvorbis-devel \
|
|
libxcb-devel \
|
|
mercurial \
|
|
pkgconfig \
|
|
texinfo \
|
|
wget \
|
|
zlib-devel
|
|
CMAKE_CMD="cmake3"
|
|
LIB_DIR_NAME="lib64"
|
|
LIB_DIR="$INSTALL_DIR/$LIB_DIR_NAME"
|
|
|
|
elif [[ "$DISTRIB_ID" == "Ubuntu" ||
|
|
"$DISTRIB_ID" == "Linuxmint" ]]; then
|
|
echo -e "\nUbuntu detected\n\n";
|
|
echo "Installing prereqs..."
|
|
sudo apt -y install \
|
|
autoconf \
|
|
automake \
|
|
build-essential \
|
|
cmake \
|
|
git-core \
|
|
libass-dev \
|
|
libfreetype6-dev \
|
|
libgnutls28-dev \
|
|
libmp3lame-dev \
|
|
libsdl2-dev \
|
|
libtool \
|
|
libva-dev \
|
|
libvdpau-dev \
|
|
libvorbis-dev \
|
|
libxcb1-dev \
|
|
libxcb-shm0-dev \
|
|
libxcb-xfixes0-dev \
|
|
meson \
|
|
ninja-build \
|
|
pkg-config \
|
|
texinfo \
|
|
wget \
|
|
yasm \
|
|
zlib1g-dev \
|
|
nasm \
|
|
libx264-dev \
|
|
libx265-dev \
|
|
libnuma-dev \
|
|
libvpx-dev \
|
|
libfdk-aac-dev \
|
|
libopus-dev \
|
|
openssl \
|
|
libssl-dev \
|
|
frei0r-plugins-dev \
|
|
libchromaprint-dev \
|
|
libgme-dev \
|
|
flite1-dev \
|
|
libcaca-dev \
|
|
libbs2b-dev \
|
|
libopenjp2-7-dev \
|
|
libopencore-amrnb-dev \
|
|
librubberband-dev \
|
|
libopenmpt-dev \
|
|
libshine-dev \
|
|
libsnappy-dev \
|
|
libsoxr-dev \
|
|
libspeex-dev \
|
|
libtheora-dev \
|
|
libtwolame-dev \
|
|
libv4l-dev \
|
|
libvidstab-dev \
|
|
libvo-amrwbenc-dev \
|
|
libxvidcore-dev \
|
|
liblzma-dev \
|
|
libbluray-dev \
|
|
libcdparanoia-dev \
|
|
libcdio-dev \
|
|
libcdio-paranoia-dev \
|
|
ladspa-sdk \
|
|
libgsm1-dev \
|
|
libvpl2 \
|
|
libwebp-dev \
|
|
libzimg-dev \
|
|
libzvbi-dev
|
|
CMAKE_CMD="cmake"
|
|
LIB_DIR_NAME="lib"
|
|
LIB_DIR="$INSTALL_DIR/$LIB_DIR_NAME"
|
|
|
|
fi
|
|
|
|
mkdir -p $SOURCES_DIR $INSTALL_DIR $BIN_DIR $LIB_DIR
|
|
|
|
echo
|
|
echo
|
|
|
|
#~ echo "Building NASM"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ wget https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.bz2 && \
|
|
#~ tar xjvf nasm-2.14.tar.bz2 && \
|
|
#~ cd nasm-2.14 && \
|
|
#~ ./autogen.sh && \
|
|
#~ PATH="$BIN_DIR:$PATH" ./configure --prefix="$INSTALL_DIR" --libdir="$LIB_DIR" && \
|
|
#~ make -j$NUM_CORES && \
|
|
#~ sudo make install
|
|
#~ echo
|
|
#~ echo
|
|
|
|
#~ echo "Building Yasm"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ wget -O yasm-1.3.0.tar.gz https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz && \
|
|
#~ tar xzvf yasm-1.3.0.tar.gz && \
|
|
#~ cd yasm-1.3.0 && \
|
|
#~ ./configure --prefix="$INSTALL_DIR" --libdir="$LIB_DIR" --disable-static && \
|
|
#~ make -j$NUM_CORES && \
|
|
#~ sudo make install
|
|
#~ echo
|
|
#~ echo
|
|
|
|
#~ echo "Building libx264"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ git -C x264 pull 2> /dev/null || git clone --depth 1 https://git.videolan.org/git/x264 && \
|
|
#~ cd x264 && \
|
|
#~ PATH="$BIN_DIR:$PATH" PKG_CONFIG_PATH="$LIB_DIR/pkgconfig" ./configure --prefix="$INSTALL_DIR" \
|
|
#~ --libdir="$LIB_DIR" --enable-shared --enable-pic \
|
|
#~ --extra-ldflags="-Wl,-rpath=$LIB_DIR,--enable-new-dtags" && \
|
|
#~ PATH="$BIN_DIR:$PATH" make -j$NUM_CORES && sudo make install
|
|
#~ echo
|
|
#~ echo
|
|
|
|
#~ echo "Building libx265"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ 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="$BIN_DIR:$PATH" $CMAKE_CMD -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
|
|
#~ -DLIB_INSTALL_DIR="$LIB_DIR_NAME" \
|
|
#~ -DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath=$LIB_DIR,--enable-new-dtags" ../../source && \
|
|
#~ PATH="$BIN_DIR:$PATH" make -j$NUM_CORES && \
|
|
#~ sudo make install
|
|
#~ # NOTE: There does not appear to be a way to disable building of static lib;
|
|
#~ # instead we remove it after the fact
|
|
#~ rm $LIB_DIR/libx265.a
|
|
#~ echo
|
|
#~ echo
|
|
|
|
#~ echo "Building libvpx"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
|
|
#~ cd libvpx && \
|
|
#~ PATH="$BIN_DIR:$PATH" ./configure --prefix="$INSTALL_DIR" --libdir="$LIB_DIR" --disable-examples \
|
|
#~ --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-shared --disable-static && \
|
|
#~ PATH="$BIN_DIR:$PATH" make -j$NUM_CORES && \
|
|
#~ sudo make install
|
|
#~ echo
|
|
#~ echo
|
|
|
|
#~ echo "Building libfdk-aac"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ git -C fdk-aac pull 2> /dev/null || git clone --depth 1 https://github.com/mstorsjo/fdk-aac && \
|
|
#~ cd fdk-aac && \
|
|
#~ autoreconf -fiv && \
|
|
#~ ./configure --prefix="$INSTALL_DIR" --libdir="$LIB_DIR" --disable-static && \
|
|
#~ make -j$NUM_CORES && \
|
|
#~ sudo make install
|
|
#~ echo
|
|
#~ echo
|
|
|
|
#~ echo "Building libmp3lame"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ wget -O lame-3.100.tar.gz https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz && \
|
|
#~ tar xzvf lame-3.100.tar.gz && \
|
|
#~ cd lame-3.100 && \
|
|
#~ PATH="$BIN_DIR:$PATH" ./configure --prefix="$INSTALL_DIR" --libdir="$LIB_DIR" --disable-static && \
|
|
#~ PATH="$BIN_DIR:$PATH" make -j$NUM_CORES && \
|
|
#~ sudo make install
|
|
#~ echo
|
|
#~ echo
|
|
|
|
#~ echo "Building libopus"
|
|
#~ cd $SOURCES_DIR && \
|
|
#~ git -C opus pull 2> /dev/null || git clone --depth 1 https://github.com/xiph/opus.git && \
|
|
#~ cd opus && \
|
|
#~ ./autogen.sh && \
|
|
#~ ./configure --prefix="$INSTALL_DIR" --libdir="$LIB_DIR" --disable-static && \
|
|
#~ make -j$NUM_CORES && \
|
|
#~ sudo make install
|
|
#~ echo
|
|
#~ echo
|
|
|
|
echo "Building libaom"
|
|
cd $SOURCES_DIR && \
|
|
git -C aom pull 2> /dev/null || git clone --depth 1 https://aomedia.googlesource.com/aom && \
|
|
mkdir aom_build && \
|
|
cd aom_build && \
|
|
PATH="$BIN_DIR:$PATH" $CMAKE_CMD -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
|
|
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath=$LIB_DIR,--enable-new-dtags" \
|
|
-DBUILD_SHARED_LIBS=ON -DENABLE_TESTS=OFF -DENABLE_NASM=ON ../aom && \
|
|
PATH="$BIN_DIR:$PATH" make -j$NUM_CORES && \
|
|
sudo make install
|
|
echo
|
|
echo
|
|
pause
|
|
|
|
|
|
echo "Building libsvtav1"
|
|
cd $SOURCES_DIR && \
|
|
# Temporarily use version 2.0.3 instead of latest: https://forums.linuxmint.com/viewtopic.php?t=435381
|
|
#~ git -C SVT-AV1 pull 2> /dev/null || git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git && \
|
|
wget https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v2.3.0/SVT-AV1-v2.3.0.tar.gz && \
|
|
tar xzvf SVT-AV1-v2.3.0.tar.gz && mv SVT-AV1-v2.3.0 SVT-AV1 && /
|
|
mkdir -p SVT-AV1/build && \
|
|
cd SVT-AV1/build && \
|
|
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
|
|
-DCMAKE_BUILD_TYPE=Release -DBUILD_DEC=OFF -DBUILD_SHARED_LIBS=ON .. && \
|
|
PATH="$BIN_DIR:$PATH" make -j$NUM_CORES && \
|
|
sudo make install
|
|
echo
|
|
echo
|
|
pause
|
|
|
|
echo "Building libdav1d"
|
|
cd $SOURCES_DIR && \
|
|
git -C dav1d pull 2> /dev/null || git clone --depth 1 https://code.videolan.org/videolan/dav1d.git && \
|
|
mkdir -p dav1d/build && \
|
|
cd dav1d/build && \
|
|
PATH="$BIN_DIR:$PATH" meson setup -Denable_tools=false -Denable_tests=false --default-library=shared .. \
|
|
--prefix "$INSTALL_DIR" --libdir="$LIB_DIR" && \
|
|
ninja && \
|
|
sudo ninja install
|
|
echo
|
|
echo
|
|
pause
|
|
|
|
echo "Building libvmaf"
|
|
cd $SOURCES_DIR &&
|
|
git clone 'https://github.com/Netflix/vmaf' 'vmaf-master' &&
|
|
mkdir -p 'vmaf-master/libvmaf/build' &&
|
|
cd 'vmaf-master/libvmaf/build' &&
|
|
meson setup -Denable_tests=false -Denable_docs=false --buildtype=release --default-library=shared '../' \
|
|
--prefix "$INSTALL_DIR" --bindir="$BIN_DIR" --libdir="$LIB_DIR" &&
|
|
ninja &&
|
|
sudo ninja install
|
|
echo
|
|
echo
|
|
pause
|
|
|
|
echo "Building VVenC (H.266/VVC)"
|
|
cd $SOURCES_DIR &&
|
|
git -C vvenc pull 2> /dev/null || git clone --depth 1 https://github.com/fraunhoferhhi/vvenc &&
|
|
cd vvenc &&
|
|
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON &&
|
|
PATH="$BIN_DIR:$PATH" make -j$(NUM_CORES) &&
|
|
sudo make -j$(NUM_CORES) install
|
|
echo
|
|
echo
|
|
pause
|
|
|
|
|
|
echo "Building ffmpeg"
|
|
cd $SOURCES_DIR && \
|
|
wget -O ffmpeg-$FFMPEG_VERSION.tar.bz2 https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 && \
|
|
tar xjvf ffmpeg-$FFMPEG_VERSION.tar.bz2 && \
|
|
cd ffmpeg-$FFMPEG_VERSION && \
|
|
PATH="$BIN_DIR:$PATH" PKG_CONFIG_PATH="$INSTALL_DIR/lib/pkgconfig:$INSTALL_DIR/lib64/pkgconfig" ./configure \
|
|
--enable-shared \
|
|
--disable-static \
|
|
--prefix="$INSTALL_DIR" \
|
|
--libdir="$LIB_DIR" \
|
|
--enable-pic \
|
|
--extra-cflags="-I$INSTALL_DIR/include" \
|
|
--extra-ldflags="-L$LIB_DIR -Wl,-rpath=$LIB_DIR,--enable-new-dtags" \
|
|
--extra-libs="-lpthread -lm" \
|
|
--enable-chromaprint \
|
|
--enable-frei0r \
|
|
--enable-gpl \
|
|
--enable-ladspa \
|
|
--enable-libaom \
|
|
--enable-libass \
|
|
--enable-libbluray \
|
|
--enable-libbs2b \
|
|
--enable-libcaca \
|
|
--enable-libcdio \
|
|
--enable-libfdk-aac \
|
|
--enable-libflite \
|
|
--enable-libfontconfig \
|
|
--enable-libfreetype \
|
|
--enable-libfribidi \
|
|
--enable-libgme \
|
|
--enable-libmp3lame \
|
|
--enable-libopenmpt \
|
|
--enable-libmp3lame \
|
|
--enable-libopus \
|
|
--enable-libpulse \
|
|
--enable-librubberband \
|
|
--enable-libshine \
|
|
--enable-libsnappy \
|
|
--enable-libsoxr \
|
|
--enable-libspeex \
|
|
--enable-libsvtav1 \
|
|
--enable-libtheora \
|
|
--enable-libtwolame \
|
|
--enable-libvidstab \
|
|
--enable-libdav1d \
|
|
--enable-libvmaf \
|
|
--enable-libvo-amrwbenc \
|
|
--enable-libvorbis \
|
|
--enable-libvpx \
|
|
--enable-libx264 \
|
|
--enable-libx265 \
|
|
--enable-libxml2 \
|
|
--enable-libxvid \
|
|
--enable-nonfree \
|
|
--enable-opengl \
|
|
--enable-openssl \
|
|
--enable-version3 \
|
|
--enable-librubberband \
|
|
--enable-libharfbuzz \
|
|
--enable-libwebp \
|
|
--enable-libzimg \
|
|
--enable-libzvbi \
|
|
--enable-libgsm \
|
|
--enable-libvvenc \
|
|
--enable-vaapi \
|
|
--enable-nonfree && \
|
|
PATH="$BIN_DIR:$PATH" make -j$NUM_CORES && \
|
|
sudo make install && \
|
|
hash -r
|
|
|
|
|
|
#~ if [ ! -f /etc/ld.so.conf.d/opt_local.conf ]; then
|
|
#~ echo "Adding /opt/local/lib path to ld cache"
|
|
#~ sudo bash -c 'echo "/opt/local/lib" > /etc/ld.so.conf.d/opt_local.conf'
|
|
#~ sudo ldconfig
|
|
#~ fi
|