-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcompile-ffmpeg.sh
executable file
·1547 lines (1210 loc) · 49.9 KB
/
compile-ffmpeg.sh
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#ffmpeg_shared="yes"
#ffmpeg_branch="release/4.3"
while [[ $# -gt 0 ]] && [[ "$1" == "--"* ]]; do
optimize='n'
opt="$1";
shift;
case "$opt" in
--ffmpeg-only=* )
compile_ffmpeg_only="${opt#*=}";;
--libs-only=* )
compile_libs_only="${opt#*=}";;
--extras=* )
compile_extras="${opt#*=}";;
--optimize=* )
optimize="${opt#*=}";;
--help )
showHelp=true;;
*);;
esac
done
if [[ $showHelp ]]; then
echo "-------------------------------------------------------------"
echo "compile with:"
echo
echo '--libs-only=[y/n] # compile only libs'
echo '--ffmpeg-only=[y/n] # compile only ffmpeg'
echo '--extras=[y/n] # compile mediainfo and MP4Box'
echo '--optimize=[y/n] # compile system optimized version'
echo '--help # show this help'
exit 0
fi
arch=$(uname -m)
system=$(uname -s)
if [[ $arch == "arm64" ]]; then
export CXX=$(which clang++)
fi
if [[ "$optimize" == "y" ]] || [[ "$arch" != "x86_64" ]]; then
tune="native"
onum=3
cpuDetect=""
vpxFlags=""
else
tune="generic"
onum=2
cpuDetect="--enable-runtime-cpudetect"
vpxFlags="--enable-postproc --enable-vp9-postproc --enable-runtime-cpu-detect"
fi
config="build_config.txt"
if [[ ! -f "$config" ]]; then
cat <<EOF > "$config"
#--enable-decklink
#--enable-libklvanc
#--disable-ffplay
#--disable-sdl2
#--enable-libfontconfig
#--enable-libaom
#--enable-libass
#--enable-libbluray
#--enable-libfdk-aac
#--enable-libfribidi
#--enable-libfreetype
#--enable-libharfbuzz
#--enable-libmp3lame
#--enable-libopus
#--enable-libsoxr
#--enable-libsrt
#--enable-librist
#--enable-libtwolame
#--enable-libvpx
#--enable-libx264
#--enable-libx265
#--enable-libzimg
#--enable-libzmq
#--enable-nonfree
#--enable-opencl
#--enable-opengl
#--enable-libopenjpeg
#--enable-openssl
#--enable-libsvtav1
#--enable-librav1e
#--enable-libdav1d
#--enable-cuda-nvcc
#--enable-cuvid
#--enable-nvenc
#--enable-nvdec
#--enable-libnpp
#--enable-libndi_newtek
#--enable-libpulse
#--enable-vulkan
#--enable-libplacebo
#--enable-libshaderc
#--enable-libvmaf
EOF
echo "-------------------------------------------------------------------------------"
echo "-------------------------------------------------------------------------------"
echo ""
echo " edit \"$config\" and activate all libs that you need"
echo ""
echo "-------------------------------------------------------------------------------"
echo "-------------------------------------------------------------------------------"
while true; do
read -r -p "run (y/n):$ " run
if [[ "$run" == 'y' ]]; then
break
elif [[ "$run" == 'n' ]]; then
exit
else
echo ""
echo "Please type 'y' or 'n'"
echo "------------------------------------"
echo ""
fi
done
fi
# --------------------------------------------------
# check system
if [[ "$system" == "Darwin" ]]; then
osExtra="-mmacosx-version-min=11"
osString="osx"
cpuCount=$( sysctl hw.ncpu | awk '{ print $2 - 1 }' )
compNasm="no"
osLib="-liconv"
osFlag=""
arch="--arch=$arch"
fpic=""
sd="gsed"
if [[ "$arch" == "x86_64" ]]; then
extraLibs="-lintl"
else
extraLibs=""
fi
else
osExtra="-static-libstdc++ -static-libgcc"
osString="nix"
cpuCount=$( nproc | awk '{ print $1 - 1 }' )
compNasm="yes"
osLib=""
osFlag="--enable-pic"
arch=""
fpic="-fPIC"
sd="sed"
extraLibs="-lpthread"
fi
get_options() {
$sd -r '# remove commented text
s/#.*//
# delete empty lines
/^\s*$/d
# remove leading whitespace
s/^\s+//
# remove trailing whitespace
s/\s+$//
' "$config" | tr -d '\r'
}
IFS=$'\n' read -d '' -r -a FFMPEG_LIBS < <(get_options)
compile="false"
buildFFmpeg="false"
EXTRA_CFLAGS="-march=$tune"
LOCALBUILDDIR="$PWD/build"
LOCALDESTDIR="$PWD/local"
export LOCALBUILDDIR LOCALDESTDIR
PKG_CONFIG_PATH="${LOCALDESTDIR}/lib/pkgconfig"
CPPFLAGS="-I${LOCALDESTDIR}/include $fpic $osExtra"
CFLAGS="-I${LOCALDESTDIR}/include -mtune=$tune -O$onum $osExtra $fpic"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-L${LOCALDESTDIR}/lib -pipe $osExtra"
export PKG_CONFIG_PATH CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
[ -d "$LOCALBUILDDIR" ] || mkdir "$LOCALBUILDDIR"
[ -d "$LOCALDESTDIR" ] || mkdir "$LOCALDESTDIR"
do_prompt() {
# from http://superuser.com/a/608509
while read -r -s -e -t 0.1; do : ; done
read -r -p "$1"
}
# get git clone, or update
do_git() {
local gitURL="$1"
local gitFolder="$2"
local gitDepth="$3"
local gitBranch="$4"
local commit="$5"
echo -ne "\033]0;compile $gitFolder\007"
if [ ! -d "$gitFolder" ]; then
if [[ $gitDepth == "noDepth" ]]; then
git clone "$gitURL" "$gitFolder"
elif [[ $gitBranch != "" ]]; then
git clone --depth 1 --single-branch -b $gitBranch "$gitURL" "$gitFolder"
else
git clone --depth 1 "$gitURL" "$gitFolder"
fi
compile="true"
cd "$gitFolder" || exit
if [[ -n $commit ]]; then
git checkout $commit
fi
else
cd "$gitFolder" || exit
oldHead=$(git rev-parse HEAD)
git reset --hard "@{u}"
if [[ -n $commit ]]; then
git checkout $commit
else
git pull origin master
fi
newHead=$(git rev-parse HEAD)
if [[ "$oldHead" != "$newHead" ]]; then
compile="true"
fi
fi
}
# get svn checkout, or update
do_svn() {
local svnURL="$1"
local svnFolder="$2"
echo -ne "\033]0;compile $svnFolder\007"
if [ ! -d "$svnFolder" ]; then
svn checkout "$svnURL" "$svnFolder"
compile="true"
cd "$svnFolder" || exit
else
cd "$svnFolder" || exit
oldRevision=$(svnversion)
svn update
newRevision=$(svnversion)
if [[ "$oldRevision" != "$newRevision" ]]; then
compile="true"
fi
fi
}
# get curl download
do_curl() {
local url="$1"
local archive="$2"
local dirName="$3"
if [[ -z $archive ]]; then
# remove arguments and filepath
archive=${url%%\?*}
archive=${archive##*/}
fi
local -r response_code=$(curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "$archive" "$url")
if [[ $response_code = "200" || $response_code = "226" ]]; then
case "$archive" in
*.tar.gz)
dirName=$( expr "$archive" : '\(.*\)\.\(tar.gz\)$' )
rm -rf "$dirName"
tar -xf "$archive"
#rm "$archive"
cd "$dirName" || exit
;;
*.tar.bz2)
dirName=$( expr "$archive" : '\(.*\)\.\(tar.bz2\)$' )
rm -rf "$dirName"
tar -xf "$archive"
rm "$archive"
cd "$dirName" || exit
;;
*.tar.xz)
if [[ -z $dirName ]]; then
dirName=$( expr "$archive" : '\(.*\)\.\(tar.xz\)$' )
fi
#rm -rf $dirName
tar -xf "$archive"
# rm "$archive"
cd "$dirName" || exit
;;
*.zip)
unzip "$archive"
rm "$archive"
;;
*.7z)
dirName=$(expr "$archive" : '\(.*\)\.\(7z\)$' )
7z x -o"$dirName" "$archive"
rm "$archive"
;;
esac
elif [[ $response_code -gt 400 ]]; then
echo "Error $response_code while downloading $URL"
echo "Try again later or <Enter> to continue"
do_prompt "if you're sure nothing depends on it."
fi
}
# check if compiled file exist
do_checkIfExist() {
local packetName="$1"
local fileName="$2"
local fileExtension=${fileName##*.}
if [[ "$fileExtension" != "a" ]]; then
if [ -f "$LOCALDESTDIR/$fileName" ]; then
echo -
echo -------------------------------------------------
echo "build $packetName done..."
echo -------------------------------------------------
echo -
compile="false"
else
echo -------------------------------------------------
echo "Build $packetName failed..."
echo "Delete the source folder under '$LOCALBUILDDIR' and start again,"
echo "or if you know there is no dependences hit enter for continue it."
read -r -p ""
sleep 5
fi
else
if [ -f "$LOCALDESTDIR/lib/$fileName" ]; then
echo -
echo -------------------------------------------------
echo "build $packetName done..."
echo -------------------------------------------------
echo -
compile="false"
else
echo -------------------------------------------------
echo "build $packetName failed..."
echo "delete the source folder under '$LOCALBUILDDIR' and start again,"
echo "or if you know there is no dependences hit enter for continue it"
read -r -p ""
sleep 5
fi
fi
}
buildLibs() {
cd "$LOCALBUILDDIR" || exit
if [[ "$system" == "Darwin" ]]; then
if [ -f "$LOCALDESTDIR/lib/libuuid.a" ]; then
echo -------------------------------------------------
echo "uuid-1.6.2 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile uuid 64Bit\007"
do_curl "https://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz"
./configure --prefix="$LOCALDESTDIR" --disable-shared
make -j "$cpuCount"
make install
do_checkIfExist uuid-1.6.2 libuuid.a
fi
fi
cd "$LOCALBUILDDIR" || exit
if [ -f "$LOCALDESTDIR/lib/libz.a" ]; then
echo -------------------------------------------------
echo "zlib-1.3.1 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile libz 64Bit\007"
do_curl "https://zlib.net/zlib-1.3.1.tar.gz"
./configure --prefix="$LOCALDESTDIR" --static
make -j "$cpuCount"
make install
do_checkIfExist zlib-1.3.1 libz.a
fi
cd "$LOCALBUILDDIR" || exit
if [ -f "$LOCALDESTDIR/lib/libiconv.a" ]; then
echo -------------------------------------------------
echo "libiconv-1.17 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile libiconv 64Bit\007"
do_curl "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz"
./configure --prefix="$LOCALDESTDIR" --disable-shared
make -j "$cpuCount"
make install
do_checkIfExist libiconv-1.17 libiconv.a
fi
cd "$LOCALBUILDDIR" || exit
if [ -f "$LOCALDESTDIR/lib/libbz2.a" ]; then
echo -------------------------------------------------
echo "bzip2-1.0.8 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile bzip2 64Bit\007"
do_curl "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz"
if [[ "$system" == "Darwin" ]]; then
$sd -ri "s/^CFLAGS=-Wall/^CFLAGS=-Wall $osExtra/g" Makefile
fi
make install PREFIX="$LOCALDESTDIR"
do_checkIfExist bzip2-1.0.8 libbz2.a
fi
cd "$LOCALBUILDDIR" || exit
if [ -f "$LOCALDESTDIR/lib/liblzma.a" ]; then
echo -------------------------------------------------
echo "xz-5.4.3 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile xz 64Bit\007"
do_curl "https://downloads.sourceforge.net/project/lzmautils/xz-5.4.3.tar.gz"
./configure --prefix="$LOCALDESTDIR" --disable-shared
make -j "$cpuCount"
make install
do_checkIfExist xz-5.4.3 liblzma.a
fi
cd "$LOCALBUILDDIR" || exit
if [ -f "$LOCALDESTDIR/lib/libpng.a" ]; then
echo -------------------------------------------------
echo "libpng-1.6.40 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile libpng 64Bit\007"
do_curl "http://prdownloads.sourceforge.net/libpng/libpng-1.6.40.tar.gz"
./configure --prefix="$LOCALDESTDIR" --disable-shared
make -j "$cpuCount"
make install
do_checkIfExist libpng-1.6.40 libpng.a
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libfribidi" ]] || [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libass" ]]; then
do_git "https://github.com/fribidi/fribidi.git" fribidi-git
if [[ $compile == "true" ]]; then
rm -rf build
mkdir build
cd build
meson setup -Ddocs=false -Dbin=false -Dtests=false --default-library=static .. --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib"
ninja
ninja install
if [[ ! -f "$LOCALDESTDIR/lib/pkgconfig/fribidi.pc" ]]; then
cp fribidi.pc "$LOCALDESTDIR/lib/pkgconfig/"
fi
do_checkIfExist fribidi-git libfribidi.a
else
echo -------------------------------------------------
echo "fribidi is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libfontconfig" ]]; then
if [ -f "$LOCALDESTDIR/lib/libexpat.a" ]; then
echo -------------------------------------------------
echo "expat2.5.0 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile expat 64Bit\007"
do_curl "https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.bz2"
./configure --prefix="$LOCALDESTDIR" --enable-shared=no --without-docbook
make -j "$cpuCount"
make install
do_checkIfExist expat-2.5.0 libexpat.a
fi
cd "$LOCALBUILDDIR" || exit
if [ -f "$LOCALDESTDIR/lib/libfreetype.a" ]; then
echo -------------------------------------------------
echo "freetype-2.13.1 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile freetype\007"
do_curl "https://sourceforge.net/projects/freetype/files/freetype2/2.13.1/freetype-2.13.1.tar.gz"
./configure --prefix="$LOCALDESTDIR" --disable-shared --with-harfbuzz=no
make -j "$cpuCount"
make install
do_checkIfExist freetype-2.13.1 libfreetype.a
$sd -ri "s/(Libs\:.*)/\1 -lpng16 -lbz2 -lz/g" "$LOCALDESTDIR/lib/pkgconfig/freetype2.pc"
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libfreetype" ]]; then
if [ -f "$LOCALDESTDIR/lib/libfontconfig.a" ]; then
echo -------------------------------------------------
echo "fontconfig-2.14.2 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile fontconfig\007"
do_curl "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.14.2.tar.gz"
./configure --prefix="$LOCALDESTDIR" --enable-shared=no
make -j "$cpuCount"
make install
do_checkIfExist fontconfig-2.14.2 libfontconfig.a
# on linux fontconfig.pc is not copyed
[[ ! -f "$LOCALDESTDIR/lib/pkgconfig/fontconfig.pc" ]] && cp fontconfig.pc "$LOCALDESTDIR/lib/pkgconfig/"
$sd -ri "s/(Libs\:.*)/\1 -lpng16 -lbz2 -lxml2 -lz -lstdc++ $osLib -llzma -lm -lexpat -luuid/g" "$LOCALDESTDIR/lib/pkgconfig/fontconfig.pc"
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libharfbuzz" ]]; then
do_git "https://github.com/harfbuzz/harfbuzz.git" harfbuzz-git
if [[ $compile == "true" ]]; then
mkdir build
cd build
meson setup --default-library=static --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" ..
ninja
ninja install
do_checkIfExist harfbuzz-git libharfbuzz.a
$sd -ri "s/(Libs\:.*)/\1 -lstdc++/g" "$LOCALDESTDIR/lib/pkgconfig/harfbuzz.pc"
else
echo -------------------------------------------------
echo "harfbuzz is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [ -f "$LOCALDESTDIR/lib/libxml2.a" ]; then
echo -------------------------------------------------
echo "libxml2-2.14.11 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile libxml2\007"
do_curl "https://codeload.github.com/GNOME/libxml2/tar.gz/refs/tags/v2.11.4" "libxml2-2.11.4.tar.gz"
if [[ ! -f ./configure ]]; then
./autogen.sh
else
make uninstall
make clean
fi
./configure --prefix="$LOCALDESTDIR" --disable-shared --enable-static --with-iconv=no --with-python=no
make -j "$cpuCount"
make install
do_checkIfExist libxml2-2.14.11 libxml2.a
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libzimg" ]]; then
do_git "https://github.com/sekrit-twc/zimg.git" zimg-git
if [[ $compile == "true" ]]; then
if [[ ! -f ./configure ]]; then
./autogen.sh
else
make uninstall
make clean
fi
git submodule update --init --recursive
./configure --prefix="$LOCALDESTDIR" --enable-shared=no
make -j "$cpuCount"
make install
do_checkIfExist zimg-git libzimg.a
$sd -ri "s/(Libs\:.*)/\1 -lstdc++/g" "$LOCALDESTDIR/lib/pkgconfig/zimg.pc"
else
echo -------------------------------------------------
echo "zimg is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libzmq" ]]; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -DZMG_STATIC"
do_git "https://github.com/zeromq/libzmq.git" libzmq-git
if [[ $compile == "true" ]]; then
if [[ ! -f ./configure ]]; then
./autogen.sh
else
make uninstall
make clean
fi
./configure --prefix="$LOCALDESTDIR" --enable-static --disable-shared
make -j "$cpuCount"
make install
do_checkIfExist libzmq-git libzmq.a
else
echo -------------------------------------------------
echo "libzmq is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libopenjpeg" ]]; then
do_git "https://github.com/uclouvain/openjpeg.git" libopenjpeg-git
if [[ $compile == "true" ]]; then
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include"
make -j "$cpuCount"
make install
do_checkIfExist libopenjpeg-git libopenjp2.a
else
echo -------------------------------------------------
echo "libopenjpeg is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-openssl" ]] || [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libsrt" ]]; then
if [ -f "$LOCALDESTDIR/lib/libssl.a" ]; then
echo -------------------------------------------------
echo "openssl-1.1.1u is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile openssl 64Bit\007"
if [[ "$system" == "Darwin" ]]; then
target="darwin64-x86_64-cc"
else
target="linux-x86_64"
fi
do_curl "https://www.openssl.org/source/openssl-1.1.1u.tar.gz"
./Configure --prefix=$LOCALDESTDIR --openssldir=$LOCALDESTDIR $target --libdir="$LOCALDESTDIR/lib" no-shared enable-camellia enable-idea enable-mdc2 enable-rfc3779 -mtune=$tune $osExtra
make depend all
make install_sw
do_checkIfExist openssl-1.1.1u libssl.a
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libsrt" ]]; then
do_git "https://github.com/Haivision/srt.git" srt-git
if [[ $compile == "true" ]]; then
mkdir build
cd build || exit
cmake .. -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DENABLE_SHARED:BOOLEAN=OFF -DUSE_STATIC_LIBSTDCXX:BOOLEAN=ON -DENABLE_CXX11:BOOLEAN=OFF -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include"
make -j "$cpuCount"
make install
do_checkIfExist srt-git libsrt.a
if [[ "$system" == "Darwin" ]]; then
extra=""
else
extra="-lpthread -ldl"
fi
$sd -ri "s/(Libs\:.*)/\1 -lstdc++ -lcrypto -lz $extra/g" "$LOCALDESTDIR/lib/pkgconfig/srt.pc"
else
echo -------------------------------------------------
echo "srt is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-librist" ]]; then
do_git "https://code.videolan.org/rist/librist.git" librist-git
if [[ $compile == "true" ]]; then
mkdir build
cd build || exit
meson setup --default-library=static --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" ..
ninja
ninja install
do_checkIfExist librist-git librist.a
else
echo -------------------------------------------------
echo "librist is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libvmaf" ]]; then
do_git "https://github.com/Netflix/vmaf.git" vmaf-git
if [[ $compile == "true" ]]; then
cd libvmaf
mkdir build
cd build || exit
meson setup --default-library=static -Denable_avx512=true -Dbuilt_in_models=true --buildtype release --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" ..
ninja
ninja install
$sd -ri "s/(Libs\:.*)/\1 -lstdc++/g" "$LOCALDESTDIR/lib/pkgconfig/libvmaf.pc"
do_checkIfExist vmaf-git libvmaf.a
else
echo -------------------------------------------------
echo "vmaf is already up to date"
echo -------------------------------------------------
fi
fi
echo "-------------------------------------------------------------------------------"
echo
echo "compile global tools and libs done..."
echo
echo "-------------------------------------------------------------------------------"
cd "$LOCALBUILDDIR" || exit
echo "-------------------------------------------------------------------------------"
echo
echo "compile audio libs"
echo
echo "-------------------------------------------------------------------------------"
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libmp3lame" ]]; then
if [ -f "$LOCALDESTDIR/lib/libmp3lame.a" ]; then
echo -------------------------------------------------
echo "lame-3.100 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile lame\007"
do_curl "https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz" lame-3.100.tar.gz
./configure --prefix="$LOCALDESTDIR" --enable-expopt=full --enable-shared=no
make -j "$cpuCount"
make install
do_checkIfExist lame-3.100 libmp3lame.a
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libtwolame" ]]; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -DLIBTWOLAME_STATIC"
if [ -f "$LOCALDESTDIR/lib/libtwolame.a" ]; then
echo -------------------------------------------------
echo "twolame-0.4.0 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile twolame 64Bit\007"
do_curl "https://sourceforge.net/projects/twolame/files/twolame/0.4.0/twolame-0.4.0.tar.gz/download" twolame-0.4.0.tar.gz
./configure --prefix="$LOCALDESTDIR" --disable-shared CPPFLAGS="$CPPFLAGS -DLIBTWOLAME_STATIC"
make -j "$cpuCount"
make install
do_checkIfExist twolame-0.4.0 libtwolame.a
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libfdk-aac" ]]; then
do_git "https://github.com/mstorsjo/fdk-aac" fdk-aac-git
if [[ $compile == "true" ]]; then
if [[ ! -f ./configure ]]; then
./autogen.sh
else
make uninstall
make clean
fi
./configure --prefix="$LOCALDESTDIR" --enable-shared=no
make -j "$cpuCount"
make install
do_checkIfExist fdk-aac-git libfdk-aac.a
else
echo -------------------------------------------------
echo "fdk-aac is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libsoxr" ]]; then
if [ -f "$LOCALDESTDIR/lib/libsoxr.a" ]; then
echo -------------------------------------------------
echo "soxr-0.1.3 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile soxr-0.1.1\007"
do_curl "https://downloads.sourceforge.net/project/soxr/soxr-0.1.3-Source.tar.xz"
mkdir build
cd build || exit
cmake .. -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DHAVE_WORDS_BIGENDIAN_EXITCODE=0 -DBUILD_SHARED_LIBS:bool=off -DBUILD_TESTS:BOOL=OFF -DWITH_OPENMP:BOOL=OFF -DUNIX:BOOL=on -Wno-dev
make -j "$cpuCount"
make install
do_checkIfExist soxr-0.1.3-Source libsoxr.a
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libopus" ]]; then
if [ -f "$LOCALDESTDIR/lib/libopus.a" ]; then
echo -------------------------------------------------
echo "opus-1.4 is already compiled"
echo -------------------------------------------------
else
echo -ne "\033]0;compile opus\007"
do_curl "https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.4.tar.gz"
./configure --prefix="$LOCALDESTDIR" --enable-shared=no --enable-static --disable-doc
make -j "$cpuCount"
make install
do_checkIfExist opus-1.4 libopus.a
fi
fi
echo "-------------------------------------------------------------------------------"
echo
echo "compile audio libs done..."
echo
echo "-------------------------------------------------------------------------------"
cd "$LOCALBUILDDIR" || exit
sleep 3
echo "-------------------------------------------------------------------------------"
echo
echo "compile video libs"
echo
echo "-------------------------------------------------------------------------------"
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libsvtav1" ]]; then
do_git "https://gitlab.com/AOMediaCodec/SVT-AV1.git" libsvtav1-git "noDepth" "" 71d8659cf1436f0ea522903e258a11824447df3a
if [[ $compile == "true" ]]; then
cd Build
rm -rf *
cmake .. -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include"
make -j "$cpuCount"
make install
do_checkIfExist libsvtav1-git libSvtAv1Enc.a
buildFFmpeg="true"
else
echo -------------------------------------------------
echo "libsvtav1-git is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libdav1d" ]]; then
do_git "https://code.videolan.org/videolan/dav1d.git" libdav1d-git
if [[ $compile == "true" ]]; then
rm -rf build
mkdir build
cd build
meson setup -Denable_tools=false -Denable_tests=false --default-library=static .. --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib"
ninja
ninja install
do_checkIfExist libdav1d-git libdav1d.a
buildFFmpeg="true"
else
echo -------------------------------------------------
echo "libdav1d-git is already up to date"
echo -------------------------------------------------
fi
fi
cd "$LOCALBUILDDIR" || exit
if [[ " ${FFMPEG_LIBS[@]} " =~ "--enable-libaom" ]]; then
do_git "https://aomedia.googlesource.com/aom" libaom-git
if [[ $compile == "true" ]]; then
if [ -d "aom_build" ]; then
cd aom_build