1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
|
#!/usr/bin/env bash
# Copyright (C) 2022 Olive Team
# SPDX-License-Identifier: GPL-3.0-or-later
# Largely based on https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
#
# Uses { command } & pattern for parallelism https://gist.github.com/thenadz/6c0584d42fb007582fbc
#
# TODO: Use advanced options such as LTO? e.g. https://code.videolan.org/videolan/x264/-/blob/master/configure
# TODO: Enable debug symbols? (Or is it opt-out?)
# TODO: Add more ffmpeg libraries? See https://raw.githubusercontent.com/jrottenberg/ffmpeg/master/docker-images/4.2/centos7/Dockerfile
set -ex
# Set up recent NASM
{
curl -fLsS -o nasm.tar.xz "https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.xz"
tar xf nasm.tar.xz
rm -f nasm.tar.xz
cd nasm*
./autogen.sh
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}"
make -j${NUM_JOBS}
make install
cd ..
rm -rf nasm*
} &
# Set up recent YASM
{
curl -fLsS -o yasm.tar.gz "http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz"
tar xf yasm.tar.gz
rm -f yasm.tar.gz
cd yasm*
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}"
make -j${NUM_JOBS}
make install
cd ..
rm -rf yasm*
} &
# join jobs, some libs depend on NASM/YASM
wait
# Set up libaom
{
git clone --depth 1 --branch "${AOM_VERSION}" "https://aomedia.googlesource.com/aom"
cd aom
mkdir _build
cd _build
cmake .. \
-DCMAKE_INSTALL_PREFIX="${OLIVE_INSTALL_PREFIX}" \
-DBUILD_SHARED_LIBS=1
cmake --build .
cmake --install .
cd ../..
rm -rf aom
} &
# Set up libx264
{
# TODO: Checkout stable branch instead of master?
git clone --depth 1 "https://code.videolan.org/videolan/x264.git"
cd x264
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--enable-shared \
--enable-pic \
--disable-cli
make
make install
cd ..
rm -rf x264
} &
# Set up libx265
{
# BitBucket dropped support for Mercurial repos
#hg clone https://bitbucket.org/multicoreware/x265
# Need to fetch tags (off by default for shallow clones) or checkout a tag to avoid pkg-config error
git clone --depth 1 --branch "${X265_VERSION}" "https://bitbucket.org/multicoreware/x265_git.git" x265
cd x265/build/linux
cmake \
-G "Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX="${OLIVE_INSTALL_PREFIX}" \
../../source
make
make install
cd ../../..
rm -rf x265
} &
# Set up libogg
{
curl -fLsS -o libogg.tar.gz "http://downloads.xiph.org/releases/ogg/libogg-${OGG_VERSION}.tar.gz"
tar xf libogg.tar.gz
rm -f libogg.tar.gz
cd libogg*
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--enable-shared
make
make install
cd ..
rm -rf libogg*
} &
# Set up libopus
{
curl -fLsS -o opus.tar.gz "https://archive.mozilla.org/pub/opus/opus-${OPUS_VERSION}.tar.gz"
tar xf opus.tar.gz
rm -f opus.tar.gz
cd opus*
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--enable-shared
make
make install
cd ..
rm -rf opus*
} &
# join jobs, libvorbis and libtheora depend on libogg
wait
# Set up libvorbis
{
curl -fLsS -o libvorbis.tar.gz "http://downloads.xiph.org/releases/vorbis/libvorbis-${VORBIS_VERSION}.tar.gz"
tar xf libvorbis.tar.gz
rm -f libvorbis.tar.gz
cd libvorbis*
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--with-ogg="${OLIVE_INSTALL_PREFIX}" \
--enable-shared
make
make install
cd ..
rm -rf libvorbis*
} &
# Set up libtheora
{
curl -fLsS -o libtheora.tar.gz "http://downloads.xiph.org/releases/theora/libtheora-${THEORA_VERSION}.tar.gz"
tar xf libtheora.tar.gz
rm -f libtheora.tar.gz
cd libtheora*
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--with-ogg="${OLIVE_INSTALL_PREFIX}" \
--enable-shared
make
make install
cd ..
rm -rf libtheora*
} &
# Set up libvpx
{
git clone --depth 1 --branch "v${VPX_VERSION}" "https://chromium.googlesource.com/webm/libvpx.git"
cd libvpx
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--enable-shared \
--enable-pic \
--enable-vp8 \
--enable-vp9 \
--enable-vp9-highbitdepth \
--as=yasm \
--disable-examples \
--disable-unit-tests \
--disable-docs \
--disable-install-bins
make
make install
cd ..
rm -rf libvpx
} &
### Set up libwebp
{
curl -fLsS -o libwebp.tar.gz "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${WEBP_VERSION}.tar.gz"
tar xf libwebp.tar.gz
rm -f libwebp.tar.gz
cd libwebp*
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--enable-shared
make
make install
cd ..
rm -rf libwebp*
} &
# Set up libmp3lame
{
curl -fLsS -o lame.tar.gz "https://downloads.sourceforge.net/project/lame/lame/${LAME_VERSION}/lame-${LAME_VERSION}.tar.gz"
tar xf lame.tar.gz
rm -f lame.tar.gz
cd lame*
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--enable-shared \
--enable-nasm \
--disable-frontend
make
make install
cd ..
rm -rf lame*
} &
### Set up xvid
{
curl -fLsS -o xvidcore.tar.gz "https://downloads.xvid.com/downloads/xvidcore-${XVID_VERSION}.tar.gz"
tar xf xvidcore.tar.gz
rm -f xvidcore.tar.gz
cd xvidcore/build/generic
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--bindir="${OLIVE_INSTALL_PREFIX}/bin"
make
make install
cd ../../..
rm -rf xvidcore
} &
# Set up openjpeg
{
curl -fLsS -o openjpeg.tar.gz "https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION}.tar.gz"
tar xf openjpeg.tar.gz
rm -f openjpeg.tar.gz
cd openjpeg*
cmake \
-DBUILD_THIRDPARTY:BOOL=ON \
-DCMAKE_INSTALL_PREFIX="${OLIVE_INSTALL_PREFIX}" \
.
make
make install
cd ..
rm -rf openjpeg*
} &
# Set up libpng
{
git clone --depth 1 "https://git.code.sf.net/p/libpng/code" libpng --branch "v${LIBPNG_VERSION}"
cd libpng
./autogen.sh
./configure \
--prefix="${OLIVE_INSTALL_PREFIX}"
make check
make install
cd ..
rm -rf libpng
} &
# join all jobs
wait
curl -fLsS -o ffmpeg.tar.xz "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz"
tar xf ffmpeg.tar.xz
cd ffmpeg*
# TODO: --enable-debug?
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH" ./configure \
--disable-doc \
--disable-ffplay \
--enable-gpl \
--enable-version3 \
--enable-shared \
--enable-libaom \
--enable-libfreetype \
--enable-libx264 \
--enable-libx265 \
--enable-libopus \
--enable-libvorbis \
--enable-libtheora \
--enable-libvpx \
--enable-libwebp \
--enable-libmp3lame \
--enable-libxvid \
--enable-libopenjpeg \
--prefix="${OLIVE_INSTALL_PREFIX}" \
--extra-libs=-lpthread \
--extra-libs=-lm \
--extra-cflags="-I${OLIVE_INSTALL_PREFIX}/include" \
--extra-ldflags="-L${OLIVE_INSTALL_PREFIX}/lib"
make -j${NUM_JOBS}
make install
cd ..
rm -rf ffmpeg*
|