├── .gitignore ├── README.md └── build.bash /.gitignore: -------------------------------------------------------------------------------- 1 | workdir/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FFmpeg for ARM-based Apple Silicon Macs 2 | 3 | I've successfully built FFmpeg on my M1 Mac Mini with the build script included in this repository which is based on [OSXExperts.NET Guide](https://www.osxexperts.net). 4 | 5 | ```bash 6 | $ ./ffmpeg 7 | ffmpeg version git-2020-12-10-6a94afb Copyright (c) 2000-2020 the FFmpeg developers 8 | built with Apple clang version 12.0.0 (clang-1200.0.32.27) 9 | configuration: --prefix=/Users/ssut/dev/ffmpeg-build/workdir/sw --extra-cflags=-fno-stack-check --arch=arm64 --cc=/usr/bin/clang --enable-fontconfig --enable-gpl --enable-libopus --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-libass --enable-libfreetype --enable-libx264 --enable-libx265 --enable-libvpx --enable-libaom --enable-libvidstab --enable-libsnappy --enable-version3 --pkg-config-flags=--static --disable-ffplay --enable-postproc --enable-nonfree --enable-runtime-cpudetect 10 | libavutil 56. 62.100 / 56. 62.100 11 | libavcodec 58.115.102 / 58.115.102 12 | libavformat 58. 65.100 / 58. 65.100 13 | libavdevice 58. 11.103 / 58. 11.103 14 | libavfilter 7. 92.100 / 7. 92.100 15 | libswscale 5. 8.100 / 5. 8.100 16 | libswresample 3. 8.100 / 3. 8.100 17 | libpostproc 55. 8.100 / 55. 8.100 18 | Hyper fast Audio and Video encoder 19 | usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... 20 | $ lipo -archs ffmpeg 21 | arm64 22 | ``` 23 | 24 | ## Dynamically linked libraries 25 | 26 | The following package(s) will be linked dynamically because it is discouraged linking statically: 27 | 28 | - glib 29 | 30 | ## Guide 31 | 32 | Before you start you must install arm64-based Homebrew to `/opt/homebrew`. 33 | 34 | 1. Clone this repository. 35 | 2. Run `./build.bash`. 36 | -------------------------------------------------------------------------------- /build.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -exuo pipefail 3 | 4 | WORKDIR="$(pwd)/workdir" 5 | mkdir -p ${WORKDIR} 6 | 7 | SRC="$WORKDIR/sw" 8 | CMPLD="$WORKDIR/compile" 9 | NUM_PARALLEL_BUILDS=$(sysctl -n hw.ncpu) 10 | 11 | if [[ -e "${CMPLD}" ]]; then 12 | rm -rf "${CMPLD}" 13 | fi 14 | 15 | mkdir -p ${SRC} 16 | mkdir -p ${CMPLD} 17 | 18 | export PATH=${SRC}/bin:$PATH 19 | export CC=clang && export PKG_CONFIG_PATH="${SRC}/lib/pkgconfig" 20 | export MACOSX_DEPLOYMENT_TARGET=11.0 21 | 22 | if [[ "$(uname -m)" == "arm64" ]]; then 23 | export ARCH=arm64 24 | else 25 | export ARCH=x86_64 26 | fi 27 | 28 | export LDFLAGS=${LDFLAGS:-} 29 | export CFLAGS=${CFLAGS:-} 30 | 31 | function ensure_package () { 32 | if [[ "$ARCH" == "arm64" ]]; then 33 | if [[ ! -e "/opt/homebrew/opt/$1" ]]; then 34 | echo "Installing $1 using Homebrew" 35 | brew install "$1" 36 | 37 | export LDFLAGS="-L/opt/homebrew/opt/$1/lib ${LDFLAGS}" 38 | export CFLAGS="-I/opt/homebrew/opt/$1/include ${CFLAGS}" 39 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/homebrew/opt/$1/lib/pkgconfig" 40 | fi 41 | else 42 | if [[ ! -e "/usr/local/opt/$1" ]]; then 43 | echo "Installing $1 using Homebrew" 44 | brew install "$1" 45 | export LDFLAGS="-L/usr/local/opt/$1/lib ${LDFLAGS}" 46 | export CFLAGS="-I/usr/local/opt/$1/include ${CFLAGS}" 47 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/$1/lib/pkgconfig" 48 | fi 49 | fi 50 | } 51 | 52 | ensure_package pkgconfig 53 | ensure_package libtool 54 | ensure_package glib 55 | 56 | if ! command -v autoreconf &> /dev/null; then 57 | brew install autoconf 58 | fi 59 | if ! command -v automake &> /dev/null; then 60 | brew install automake 61 | fi 62 | if ! command -v cmake &> /dev/null; then 63 | brew install cmake 64 | fi 65 | 66 | echo "Cloning required git repositories" 67 | git clone --depth 1 -b master https://code.videolan.org/videolan/x264.git $CMPLD/x264 & 68 | git clone --depth 1 -b origin https://github.com/rbrito/lame.git $CMPLD/lame & 69 | git clone --depth 1 -b main https://github.com/webmproject/libvpx $CMPLD/libvpx & 70 | git clone --depth 1 -b master https://github.com/FFmpeg/FFmpeg $CMPLD/ffmpeg & 71 | git clone --depth 1 -b v2.0.1 https://aomedia.googlesource.com/aom.git $CMPLD/aom & 72 | wait 73 | 74 | curl -Ls -o - https://bitbucket.org/multicoreware/x265_git/downloads/x265_3.3.tar.gz | tar zxf - -C $CMPLD/ & 75 | # statically linking glibc is discouraged 76 | # echo "Downloading: glib (2.66.2)" 77 | # curl -Ls -o - https://download.gnome.org/sources/glib/2.66/glib-2.66.2.tar.xz | tar Jxf - -C $CMPLD/ 78 | # curl -o "$CMPLD/glib-2.66.2/hardcoded-patchs.diff" https://raw.githubusercontent.com/Homebrew/formula-patches/6164294a75541c278f3863b111791376caa3ad26/glib/hardcoded-paths.diff 79 | echo "Downloading: fribidi (1.0.10)" 80 | {(curl -Ls -o - https://github.com/fribidi/fribidi/releases/download/v1.0.10/fribidi-1.0.10.tar.xz | tar Jxf - -C $CMPLD/) &}; 81 | echo "Downloading: vid.stab (1.1.0)" 82 | curl -Ls -o - https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz | tar zxf - -C $CMPLD/ 83 | curl -s -o "$CMPLD/vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch 84 | echo "Downloading: snappy (1.1.8)" 85 | {(curl -Ls -o - https://github.com/google/snappy/archive/1.1.8.tar.gz | tar zxf - -C $CMPLD/) &}; 86 | echo "Downloading: enca (1.19)" 87 | {(curl -Ls -o - https://dl.cihar.com/enca/enca-1.19.tar.gz | tar zxf - -C $CMPLD/) &}; 88 | echo "Downloading: libiconv (1.16)" 89 | {(curl -Ls -o - https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz | tar zxf - -C $CMPLD/) &}; 90 | echo "Downloading: zlib (1.2.11)" 91 | {(curl -Ls -o - https://zlib.net/fossils/zlib-1.2.11.tar.gz | tar zxf - -C $CMPLD/) &}; 92 | echo "Downloading: libtheora (1.1.1)" 93 | {(curl -Ls -o - http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 | tar xf - -C $CMPLD/) &}; 94 | echo "Downloading: expat (2.2.10)" 95 | {(curl -Ls -o - https://github.com/libexpat/libexpat/releases/download/R_2_2_10/expat-2.2.10.tar.gz | tar zxf - -C $CMPLD/) &}; 96 | echo "Downloading: freetype (2.10.4)" 97 | {(curl -Ls -o - https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz | tar zxf - -C $CMPLD/) &}; 98 | echo "Downloading: gettext (0.21)" 99 | {(curl -Ls -o - https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.xz | tar Jxf - -C $CMPLD/) &}; 100 | echo "Downloading: fontconfig (2.13.93)" 101 | {(curl -Ls -o - https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.93.tar.gz | tar zxf - -C $CMPLD/) &}; 102 | echo "Downloading: libass (0.15.0)" 103 | {(curl -Ls -o - https://github.com/libass/libass/releases/download/0.15.0/libass-0.15.0.tar.gz | tar zxf - -C $CMPLD/) &}; 104 | echo "Downloading: yasm (1.3.0)" 105 | {(curl -Ls -o - http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz | tar zxf - -C $CMPLD/) &}; 106 | echo "Downloading: pkg-config (0.29.2)" 107 | {(curl -Ls -o - https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz | tar zxf - -C $CMPLD/) &}; 108 | echo "Downloading: nasm (2.15.05)" 109 | {(curl -Ls -o - https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.gz | tar zxf - -C $CMPLD/) &}; 110 | echo "Downloading: libvorbis (1.3.7)" 111 | {(curl -Ls -o - https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.7.tar.gz | tar zxf - -C $CMPLD/) &}; 112 | echo "Downloading: libopus (1.3.1)" 113 | {(curl -Ls -o - https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz | tar zxf - -C $CMPLD/) &}; 114 | echo "Downloading: harfbuzz (2.7.2)" 115 | {(curl -Ls -o - https://github.com/harfbuzz/harfbuzz/releases/download/2.7.2/harfbuzz-2.7.2.tar.xz | tar Jxf - -C $CMPLD/) &}; 116 | echo "Downloading: libogg (1.3.4)" 117 | curl -Ls -o - https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.4.tar.gz | tar zxf - -C $CMPLD/ 118 | curl -s -o "$CMPLD/libogg-1.3.4/fix_unsigned_typedefs.patch" "https://github.com/xiph/ogg/commit/c8fca6b4a02d695b1ceea39b330d4406001c03ed.patch?full_index=1" 119 | 120 | wait 121 | 122 | function build_fribidi () { 123 | if [[ ! -e "${SRC}/lib/pkgconfig/fribidi.pc" ]]; then 124 | echo '♻️ ' Start compiling FRIBIDI 125 | cd ${CMPLD} 126 | cd fribidi-1.0.10 127 | ./configure --prefix=${SRC} --disable-debug --disable-dependency-tracking --disable-silent-rules --disable-shared --enable-static 128 | make -j ${NUM_PARALLEL_BUILDS} 129 | make install 130 | fi 131 | } 132 | 133 | function build_yasm () { 134 | if [[ ! -e "${SRC}/lib/libyasm.a" ]]; then 135 | echo '♻️ ' Start compiling YASM 136 | cd ${CMPLD} 137 | cd yasm-1.3.0 138 | ./configure --prefix=${SRC} 139 | make -j ${NUM_PARALLEL_BUILDS} 140 | make install 141 | fi 142 | } 143 | 144 | function build_aom () { 145 | if [[ ! -e "${SRC}/lib/pkgconfig/aom.pc" ]]; then 146 | echo '♻️ ' Start compiling AOM 147 | cd ${CMPLD} 148 | cd aom 149 | mkdir aom_build 150 | cd aom_build 151 | 152 | AOM_CMAKE_PARAMS="-DENABLE_DOCS=off -DENABLE_EXAMPLES=off -DENABLE_TESTDATA=off -DENABLE_TESTS=off -DENABLE_TOOLS=off -DCMAKE_INSTALL_PREFIX:PATH=${SRC} -DLIBTYPE=STATIC" 153 | if [[ "$ARCH" == "arm64" ]]; then 154 | AOM_CMAKE_PARAMS="$AOM_CMAKE_PARAMS -DCONFIG_RUNTIME_CPU_DETECT=0" 155 | fi 156 | cmake ${CMPLD}/aom $AOM_CMAKE_PARAMS 157 | make -j ${NUM_PARALLEL_BUILDS} 158 | make install 159 | fi 160 | } 161 | 162 | function build_nasm () { 163 | if [[ ! -e "${SRC}/bin/nasm" ]]; then 164 | echo '♻️ ' Start compiling NASM 165 | # 166 | # compile NASM 167 | # 168 | cd ${CMPLD} 169 | cd nasm-2.15.05 170 | ./configure --prefix=${SRC} 171 | make -j ${NUM_PARALLEL_BUILDS} 172 | make install 173 | fi 174 | } 175 | 176 | function build_pkgconfig () { 177 | if [[ ! -e "${SRC}/bin/pkg-config" ]]; then 178 | echo '♻️ ' Start compiling pkg-config 179 | cd ${CMPLD} 180 | cd pkg-config-0.29.2 181 | export LDFLAGS="-framework Foundation -framework Cocoa" 182 | ./configure --prefix=${SRC} --with-pc-path=${SRC}/lib/pkgconfig --with-internal-glib --disable-shared --enable-static 183 | make -j ${NUM_PARALLEL_BUILDS} 184 | make install 185 | unset LDFLAGS 186 | fi 187 | } 188 | 189 | function build_zlib () { 190 | if [[ ! -e "${SRC}/lib/pkgconfig/zlib.pc" ]]; then 191 | echo '♻️ ' Start compiling ZLIB 192 | cd ${CMPLD} 193 | cd zlib-1.2.11 194 | ./configure --prefix=${SRC} 195 | make -j ${NUM_PARALLEL_BUILDS} 196 | make install 197 | rm ${SRC}/lib/libz.so* || true 198 | rm ${SRC}/lib/libz.* || true 199 | fi 200 | } 201 | 202 | function build_lame () { 203 | if [[ ! -e "${SRC}/lib/libmp3lame.a" ]]; then 204 | cd ${CMPLD} 205 | cd lame 206 | ./configure --prefix=${SRC} --disable-shared --enable-static 207 | make -j ${NUM_PARALLEL_BUILDS} 208 | make install 209 | fi 210 | } 211 | 212 | function build_x264 () { 213 | if [[ ! -e "${SRC}/lib/pkgconfig/x264.pc" ]]; then 214 | echo '♻️ ' Start compiling X264 215 | cd ${CMPLD} 216 | cd x264 217 | ./configure --prefix=${SRC} --disable-shared --enable-static --enable-pic 218 | make -j ${NUM_PARALLEL_BUILDS} 219 | make install 220 | make install-lib-static 221 | fi 222 | } 223 | 224 | function build_x265 () { 225 | if [[ ! -e "${SRC}/lib/pkgconfig/x265.pc" ]]; then 226 | echo '♻️ ' Start compiling X265 227 | rm -f ${SRC}/include/x265*.h 2>/dev/null 228 | rm -f ${SRC}/lib/libx265.a 2>/dev/null 229 | 230 | echo '♻️ ' X265 12bit 231 | cd ${CMPLD} 232 | cd x265_3.3/source 233 | cmake -DCMAKE_INSTALL_PREFIX:PATH=${SRC} -DHIGH_BIT_DEPTH=ON -DMAIN12=ON -DENABLE_SHARED=NO -DEXPORT_C_API=NO -DENABLE_CLI=OFF . 234 | make -j ${NUM_PARALLEL_BUILDS} 235 | mv libx265.a libx265_main12.a 236 | make clean-generated 237 | rm CMakeCache.txt 238 | 239 | echo '♻️ ' X265 10bit 240 | cd ${CMPLD} 241 | cd x265_3.3/source 242 | cmake -DCMAKE_INSTALL_PREFIX:PATH=${SRC} -DMAIN10=ON -DHIGH_BIT_DEPTH=ON -DENABLE_SHARED=NO -DEXPORT_C_API=NO -DENABLE_CLI=OFF . 243 | make clean 244 | make -j ${NUM_PARALLEL_BUILDS} 245 | mv libx265.a libx265_main10.a 246 | make clean-generated && rm CMakeCache.txt 247 | 248 | echo '♻️ ' X265 full 249 | cd ${CMPLD} 250 | cd x265_3.3/source 251 | cmake -DCMAKE_INSTALL_PREFIX:PATH=${SRC} -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_12BIT=ON -DLINKED_10BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF . 252 | make clean 253 | make -j ${NUM_PARALLEL_BUILDS} 254 | 255 | mv libx265.a libx265_main.a 256 | libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null 257 | make install 258 | fi 259 | } 260 | 261 | function build_vpx () { 262 | if [[ ! -e "${SRC}/lib/pkgconfig/vpx.pc" ]]; then 263 | echo '♻️ ' Start compiling VPX 264 | cd ${CMPLD} 265 | cd libvpx 266 | ./configure --prefix=${SRC} --enable-vp8 --enable-postproc --enable-vp9-postproc --enable-vp9-highbitdepth --disable-examples --disable-docs --enable-multi-res-encoding --disable-unit-tests --enable-pic --disable-shared 267 | make -j ${NUM_PARALLEL_BUILDS} 268 | make install 269 | fi 270 | } 271 | 272 | function build_expat () { 273 | if [[ ! -e "${SRC}/lib/pkgconfig/expat.pc" ]]; then 274 | echo '♻️ ' Start compiling EXPAT 275 | cd ${CMPLD} 276 | cd expat-2.2.10 277 | ./configure --prefix=${SRC} --disable-shared --enable-static 278 | make -j ${NUM_PARALLEL_BUILDS} 279 | make install 280 | fi 281 | } 282 | 283 | function build_libiconv () { 284 | if [[ ! -e "${SRC}/lib/libiconv.a" ]]; then 285 | echo '♻️ ' Start compiling LIBICONV 286 | cd ${CMPLD} 287 | cd libiconv-1.16 288 | ./configure --prefix=${SRC} --disable-shared --enable-static 289 | make -j ${NUM_PARALLEL_BUILDS} 290 | make install 291 | fi 292 | } 293 | 294 | function build_enca () { 295 | if [[ ! -d "${SRC}/libexec/enca" ]]; then 296 | echo '♻️ ' Start compiling ENCA 297 | cd ${CMPLD} 298 | cd enca-1.19 299 | ./configure --prefix=${SRC} --disable-dependency-tracking --disable-shared --enable-static 300 | make -j ${NUM_PARALLEL_BUILDS} 301 | make install 302 | fi 303 | } 304 | 305 | function build_freetype () { 306 | if [[ ! -e "${SRC}/lib/pkgconfig/freetype2.pc" ]]; then 307 | echo '♻️ ' Start compiling FREETYPE 308 | cd ${CMPLD} 309 | cd freetype-2.10.4 310 | ./configure --prefix=${SRC} --disable-shared --enable-static 311 | make -j ${NUM_PARALLEL_BUILDS} 312 | make install 313 | fi 314 | } 315 | 316 | function build_gettext () { 317 | if [[ ! -e "${SRC}/lib/pkgconfig/gettext.pc" ]]; then 318 | echo '♻️ ' Start compiling gettext 319 | cd ${CMPLD} 320 | cd gettext-0.21 321 | ./configure --prefix=${SRC} --disable-dependency-tracking --disable-silent-rules --disable-debug --disable-shared --enable-static \ 322 | --with-included-gettext --with-included-glib --with-includedlibcroco --with-included-libunistring --with-emacs \ 323 | --disable-java --disable-csharp --without-git --without-cvs --without-xz 324 | make -j ${NUM_PARALLEL_BUILDS} 325 | make install 326 | fi 327 | } 328 | 329 | function build_fontconfig () { 330 | if [[ ! -e "${SRC}/lib/pkgconfig/fontconfig.pc" ]]; then 331 | echo '♻️ ' Start compiling FONTCONFIG 332 | cd ${CMPLD} 333 | cd fontconfig-2.13.93 334 | ./configure --prefix=${SRC} --enable-iconv --disable-libxml2 --disable-shared --enable-static --disable-docs 335 | make -j ${NUM_PARALLEL_BUILDS} 336 | make install 337 | fi 338 | } 339 | 340 | function build_harfbuzz () { 341 | if [[ ! -e "${SRC}/lib/pkgconfig/harfbuzz.pc" ]]; then 342 | echo '♻️ ' Start compiling harfbuzz 343 | cd ${CMPLD} 344 | cd harfbuzz-2.7.2 345 | sed -i -e 's/unsigned int size0, size1, supp_size;/unsigned int size0, size1;/g' ./src/hb-subset-cff1.cc 346 | sed -i -e 's/supp_size = 0;//g' ./src/hb-subset-cff1.cc 347 | sed -i -e 's/supp_size += SuppEncoding::static_size \* supp_codes.length;//g' ./src/hb-subset-cff1.cc 348 | ./configure --prefix=${SRC} --disable-shared --enable-static 349 | make -j ${NUM_PARALLEL_BUILDS} 350 | make install 351 | fi 352 | } 353 | 354 | function build_ass () { 355 | if [[ ! -e "${SRC}/lib/pkgconfig/libass.pc" ]]; then 356 | cd ${CMPLD} 357 | cd libass-0.15.0 358 | autoreconf -i 359 | ./configure --prefix=${SRC} --disable-dependency-tracking --disable-shread --enable-static 360 | make -j ${NUM_PARALLEL_BUILDS} 361 | make install 362 | fi 363 | } 364 | 365 | function build_opus () { 366 | if [[ ! -e "${SRC}/lib/pkgconfig/opus.pc" ]]; then 367 | echo '♻️ ' Start compiling OPUS 368 | cd ${CMPLD} 369 | cd opus-1.3.1 370 | ./configure --prefix=${SRC} --disable-shared --enable-static 371 | make -j ${NUM_PARALLEL_BUILDS} 372 | make install 373 | fi 374 | } 375 | 376 | function build_ogg () { 377 | if [[ ! -e "${SRC}/lib/pkgconfig/ogg.pc" ]]; then 378 | echo '♻️ ' Start compiling LIBOGG 379 | cd ${CMPLD} 380 | cd libogg-1.3.4 381 | patch -p1 < ./fix_unsigned_typedefs.patch 382 | ./configure --prefix=${SRC} --disable-shared --enable-static 383 | make -j ${NUM_PARALLEL_BUILDS} 384 | make install 385 | fi 386 | } 387 | 388 | function build_vorbis () { 389 | if [[ ! -e "${SRC}/lib/pkgconfig/vorbis.pc" ]]; then 390 | echo '♻️ ' Start compiling LIBVORBIS 391 | cd ${CMPLD} 392 | cd libvorbis-1.3.7 393 | ./configure --prefix=${SRC} --with-ogg-libraries=${SRC}/lib --with-ogg-includes=${SRC}/include/ --enable-static --disable-shared --build=x86_64 394 | make -j ${NUM_PARALLEL_BUILDS} 395 | make install 396 | fi 397 | } 398 | 399 | function build_theora () { 400 | if [[ ! -e "${SRC}/lib/pkgconfig/theora.pc" ]]; then 401 | echo '♻️ ' Start compiling THEORA 402 | cd ${CMPLD} 403 | cd libtheora-1.1.1 404 | ./configure --prefix=${SRC} --disable-asm --with-ogg-libraries=${SRC}/lib --with-ogg-includes=${SRC}/include/ --with-vorbis-libraries=${SRC}/lib --with-vorbis-includes=${SRC}/include/ --enable-static --disable-shared 405 | make -j ${NUM_PARALLEL_BUILDS} 406 | make install 407 | fi 408 | } 409 | 410 | function build_vidstab () { 411 | if [[ ! -e "${SRC}/lib/pkgconfig/vidstab.pc" ]]; then 412 | echo '♻️ ' Start compiling Vid-stab 413 | cd ${CMPLD} 414 | cd vid.stab-1.1.0 415 | patch -p1 < fix_cmake_quoting.patch 416 | cmake . -DCMAKE_INSTALL_PREFIX:PATH=${SRC} -DLIBTYPE=STATIC -DBUILD_SHARED_LIBS=OFF -DUSE_OMP=OFF -DENABLE_SHARED=off 417 | make -j ${NUM_PARALLEL_BUILDS} 418 | make install 419 | fi 420 | } 421 | 422 | function build_snappy () { 423 | if [[ ! -e "${SRC}/lib/libsnappy.a" ]]; then 424 | echo '♻️ ' Start compiling Snappy 425 | cd ${CMPLD} 426 | cd snappy-1.1.8 427 | cmake . -DCMAKE_INSTALL_PREFIX:PATH=${SRC} -DLIBTYPE=STATIC -DENABLE_SHARED=off 428 | make -j ${NUM_PARALLEL_BUILDS} 429 | make install 430 | fi 431 | } 432 | 433 | function build_ffmpeg () { 434 | echo '♻️ ' Start compiling FFMPEG 435 | cd ${CMPLD} 436 | cd ffmpeg 437 | export LDFLAGS="-L${SRC}/lib ${LDFLAGS:-}" 438 | export CFLAGS="-I${SRC}/include ${CFLAGS:-}" 439 | export LDFLAGS="$LDFLAGS -lexpat -lenca -lfribidi -liconv -lstdc++ -lfreetype -framework CoreText -framework VideoToolbox" 440 | ./configure --prefix=${SRC} --extra-cflags="-fno-stack-check" --arch=${ARCH} --cc=/usr/bin/clang \ 441 | --enable-fontconfig --enable-gpl --enable-libopus --enable-libtheora --enable-libvorbis \ 442 | --enable-libmp3lame --enable-libass --enable-libfreetype --enable-libx264 --enable-libx265 --enable-libvpx \ 443 | --enable-libaom --enable-libvidstab --enable-libsnappy --enable-version3 --pkg-config-flags=--static \ 444 | --disable-ffplay --enable-postproc --enable-nonfree --enable-runtime-cpudetect 445 | echo "build start" 446 | start_time="$(date -u +%s)" 447 | make -j ${NUM_PARALLEL_BUILDS} 448 | end_time="$(date -u +%s)" 449 | elapsed="$(($end_time-$start_time))" 450 | make install 451 | echo "[FFmpeg] $elapsed seconds elapsed for build" 452 | } 453 | 454 | total_start_time="$(date -u +%s)" 455 | build_fribidi 456 | build_yasm 457 | build_aom 458 | build_nasm 459 | build_pkgconfig 460 | build_zlib 461 | build_lame 462 | build_x264 463 | build_x265 464 | build_vpx 465 | build_expat 466 | build_libiconv 467 | build_enca 468 | build_freetype 469 | if [[ "$ARCH" == "arm64" ]]; then 470 | build_gettext 471 | fi 472 | build_fontconfig 473 | build_harfbuzz 474 | build_ass 475 | build_opus 476 | build_ogg 477 | build_vorbis 478 | build_theora 479 | build_vidstab 480 | build_snappy 481 | build_ffmpeg 482 | total_end_time="$(date -u +%s)" 483 | total_elapsed="$(($total_end_time-$total_start_time))" 484 | echo "Total $total_elapsed seconds elapsed for build" 485 | --------------------------------------------------------------------------------