@@ -8,11 +8,20 @@ VERSION=1.21
8
8
CWD=$( pwd)
9
9
PACKAGES=" $CWD /packages"
10
10
WORKSPACE=" $CWD /workspace"
11
- CFLAGS=" -I$WORKSPACE /include"
11
+ CFLAGS=' -I$WORKSPACE/include'
12
12
LDFLAGS=" -L$WORKSPACE /lib"
13
13
LDEXEFLAGS=" "
14
14
EXTRALIBS=" -ldl -lpthread -lm -lz"
15
+ MACOS_M1=false
15
16
CONFIGURE_OPTIONS=()
17
+ # Check for Apple Silicon
18
+ if [[ ( " $( uname -m) " == " arm64" ) && ( " $OSTYPE " == " darwin" * ) ]]; then
19
+ # If arm64 AND darwin (macOS)
20
+ export ARCH=arm64
21
+ export MACOSX_DEPLOYMENT_TARGET=11.0
22
+ MACOS_M1=true
23
+ fi
24
+
16
25
17
26
# Speed up the process
18
27
# Env Var NUMJOBS overrides automatic detection
@@ -146,6 +155,19 @@ build_done () {
146
155
touch " $PACKAGES /$1 .done"
147
156
}
148
157
158
+ verify_binary_type () {
159
+ BINARY_TYPE=$( file $WORKSPACE /bin/ffmpeg | sed -n ' s/^.*\:\ \(.*$\)/\1/p' )
160
+ echo " "
161
+ case $BINARY_TYPE in
162
+ " Mach-O 64-bit executable arm64" )
163
+ echo " Successfully built Apple Silicon (M1) for ${OSTYPE} : ${BINARY_TYPE} "
164
+ ;;
165
+ * )
166
+ echo " Successfully built binary for ${OSTYPE} : ${BINARY_TYPE} "
167
+ ;;
168
+ esac
169
+ }
170
+
149
171
cleanup () {
150
172
remove_dir " $PACKAGES "
151
173
remove_dir " $WORKSPACE "
@@ -350,11 +372,15 @@ if build "zlib"; then
350
372
fi
351
373
352
374
if build " openssl" ; then
353
- download " https://www.openssl.org/source/openssl-1.1.1h.tar.gz"
354
- execute ./config --prefix=" ${WORKSPACE} " --openssldir=" ${WORKSPACE} " --with-zlib-include=" ${WORKSPACE} " /include/ --with-zlib-lib=" ${WORKSPACE} " /lib no-shared zlib
375
+ download " https://www.openssl.org/source/openssl-1.1.1i.tar.gz"
376
+ if $MACOS_M1 ; then
377
+ sed -n ' s/\(##### GNU Hurd\)/"darwin64-arm64-cc" => { \n inherit_from => [ "darwin-common", asm("aarch64_asm") ],\n CFLAGS => add("-Wall"),\n cflags => add("-arch arm64 "),\n lib_cppflags => add("-DL_ENDIAN"),\n bn_ops => "SIXTY_FOUR_BIT_LONG", \n perlasm_scheme => "macosx", \n}, \n\1/g' Configurations/10-main.conf
378
+ execute ./configure --prefix=" ${WORKSPACE} " no-shared no-asm darwin64-arm64-cc
379
+ else
380
+ execute ./config --prefix=" ${WORKSPACE} " --openssldir=" ${WORKSPACE} " --with-zlib-include=" ${WORKSPACE} " /include/ --with-zlib-lib=" ${WORKSPACE} " /lib no-shared zlib
381
+ fi
355
382
execute make -j $MJOBS
356
383
execute make install_sw
357
-
358
384
build_done " openssl"
359
385
fi
360
386
CONFIGURE_OPTIONS+=(" --enable-openssl" )
@@ -386,13 +412,16 @@ CONFIGURE_OPTIONS+=("--enable-libsvtav1")
386
412
# #
387
413
388
414
if build " x264" ; then
389
- download " https://code.videolan.org/videolan/x264/-/archive/stable/x264-stable.tar.bz2"
415
+ download " https://code.videolan.org/videolan/x264/-/archive/0d754ec36013fee82978496cd56fbd48824910b3/x264-0d754ec36013fee82978496cd56fbd48824910b3.tar.gz" " x264-0d754ec.tar.gz"
416
+ cd " ${PACKAGES} " /x264-0d754ec
417
+
390
418
391
419
if [[ " $OSTYPE " == " linux-gnu" ]]; then
392
420
execute ./configure --prefix=" ${WORKSPACE} " --enable-static --enable-pic CXXFLAGS=" -fPIC"
393
421
else
394
422
execute ./configure --prefix=" ${WORKSPACE} " --enable-static --enable-pic
395
423
fi
424
+
396
425
397
426
execute make -j $MJOBS
398
427
execute make install
@@ -405,6 +434,7 @@ CONFIGURE_OPTIONS+=("--enable-libx264")
405
434
if build " x265" ; then
406
435
download " https://github.com/videolan/x265/archive/Release_3.5.tar.gz" " x265-3.5.tar.gz"
407
436
cd build/linux || exit
437
+
408
438
execute cmake -DCMAKE_INSTALL_PREFIX=" ${WORKSPACE} " -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source
409
439
execute make -j $MJOBS
410
440
execute make install
@@ -455,6 +485,13 @@ CONFIGURE_OPTIONS+=("--enable-libxvid")
455
485
456
486
if build " vid_stab" ; then
457
487
download " https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz" " vid.stab-1.1.0.tar.gz"
488
+
489
+ if $MACOS_M1 ; then
490
+
491
+ curl -s -o " $PACKAGES /vid.stab-1.1.0/fix_cmake_quoting.patch" https://raw.githubusercontent.com/Homebrew/formula-patches/5bf1a0e0cfe666ee410305cece9c9c755641bfdf/libvidstab/fix_cmake_quoting.patch
492
+ patch -p1 < fix_cmake_quoting.patch
493
+ fi
494
+
458
495
execute cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=" ${WORKSPACE} " -DUSE_OMP=OFF -DENABLE_SHARED=off .
459
496
execute make
460
497
execute make install
@@ -467,7 +504,11 @@ if build "av1"; then
467
504
download " https://aomedia.googlesource.com/aom/+archive/b52ee6d44adaef8a08f6984390de050d64df9faa.tar.gz" " av1.tar.gz" " av1"
468
505
make_dir " $PACKAGES " /aom_build
469
506
cd " $PACKAGES " /aom_build || exit
470
- execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX=" ${WORKSPACE} " -DCMAKE_INSTALL_LIBDIR=lib " $PACKAGES " /av1
507
+ if $MACOS_M1 ; then
508
+ execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX=" ${WORKSPACE} " -DCMAKE_INSTALL_LIBDIR=lib -DCONFIG_RUNTIME_CPU_DETECT=0 " $PACKAGES " /av1
509
+ else
510
+ execute cmake -DENABLE_TESTS=0 -DCMAKE_INSTALL_PREFIX=" ${WORKSPACE} " -DCMAKE_INSTALL_LIBDIR=lib " $PACKAGES " /av1
511
+ fi
471
512
execute make -j $MJOBS
472
513
execute make install
473
514
@@ -573,7 +614,7 @@ CONFIGURE_OPTIONS+=("--enable-libwebp")
573
614
# #
574
615
575
616
if build " libsdl" ; then
576
- download " https://www.libsdl.org/release/SDL2-2.0.12 .tar.gz"
617
+ download " https://www.libsdl.org/release/SDL2-2.0.14 .tar.gz"
577
618
execute ./configure --prefix=" ${WORKSPACE} " --disable-shared --enable-static
578
619
execute make -j $MJOBS
579
620
execute make install
@@ -665,9 +706,11 @@ execute make install
665
706
666
707
INSTALL_FOLDER=" /usr/bin"
667
708
if [[ " $OSTYPE " == " darwin" * ]]; then
668
- INSTALL_FOLDER=" /usr/local/bin"
709
+ INSTALL_FOLDER=" /usr/local/bin"
669
710
fi
670
711
712
+ verify_binary_type
713
+
671
714
echo " "
672
715
echo " Building done. The following binaries can be found here:"
673
716
echo " - ffmpeg: $WORKSPACE /bin/ffmpeg"
@@ -695,11 +738,11 @@ elif [[ ! "$SKIPINSTALL" == "yes" ]]; then
695
738
if command_exists " sudo" ; then
696
739
sudo cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /ffmpeg"
697
740
sudo cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /ffprobe"
698
- sudo cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
741
+ sudo cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
699
742
else
700
743
cp " $WORKSPACE /bin/ffmpeg" " $INSTALL_FOLDER /ffmpeg"
701
744
cp " $WORKSPACE /bin/ffprobe" " $INSTALL_FOLDER /ffprobe"
702
- cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
745
+ cp " $WORKSPACE /bin/ffplay" " $INSTALL_FOLDER /ffplay"
703
746
fi
704
747
echo " Done. FFmpeg is now installed to your system."
705
748
;;
0 commit comments