-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetupCentOS7.sh
executable file
·341 lines (307 loc) · 9.29 KB
/
setupCentOS7.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
#!/bin/sh
#
# Setup an FFmpeg with the ability to
# per title encode via image hashes
# hamming distance values
# should run on Linux, other systems untested
#
# requires:
#
# git
# wget
# development tools
set -e
# install deps
if [ ! -e /usr/bin/wget ]; then
sudo yum -y -q install wget
fi
if [ ! -e /usr/bin/git ]; then
sudo yum -y -q install git
fi
if [ ! -e /usr/bin/clang ]; then
sudo yum -y -q install clang
fi
if [ ! -e /usr/bin/cargo ]; then
sudo yum -y -q install cargo
fi
if [ ! -e /usr/bin/rustc ]; then
sudo yum -y -q install rust
fi
if [ ! -e /usr/bin/cmake3 ]; then
sudo yum -y -q install cmake3
sudo ln -s /usr/bin/cmake3 /usr/bin/cmake
fi
if [ ! -e /usr/bin/cmake ]; then
sudo ln -s /usr/bin/cmake3 /usr/bin/cmake
fi
if [ ! -e /usr/bin/gnuplot ]; then
sudo yum -y -q install gnuplot
fi
if [ ! -e /usr/bin/mediainfo ]; then
sudo yum -y -q install mediainfo
fi
if [ ! -e /usr/include/freetype2 ]; then
sudo yum -y -q install freetype-devel
fi
if [ ! -e /usr/lib/libass.a ]; then
sudo yum -y -q install libass-devel
fi
if [ ! -e /usr/include/fontconfig ]; then
sudo yum -y -q install fontconfig-devel
fi
# pip for python3
if [ ! -e /usr/bin/pip3 ]; then
sudo yum -y -q install python3-pip
fi
if [ ! -e /usr/bin/meson ]; then
sudo python3 -m pip install meson
sudo yum -y -q install meson
fi
if [ ! -e /usr/local/bin/ninja ]; then
sudo python3 -m pip install ninja
fi
if [ ! -e /usr/bin/openssl ]; then
sudo yum -y -q install openssl-devel
fi
## get opencv and opencv_contrib
if [ ! -d "opencv" ]; then
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 3.4
cd ../
fi
if [ ! -d "opencv_contrib" ]; then
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout 3.4
cd ../
fi
if [ ! -d "x264" ]; then
git clone https://code.videolan.org/videolan/x264.git
cd x264
git checkout stable
cd ../
fi
if [ ! -d "libvpx" ]; then
git clone https://github.com/webmproject/libvpx.git libvpx
cd libvpx
git checkout v1.8.1
cd ../
fi
if [ ! -d "aom" ]; then
git clone https://aomedia.googlesource.com/aom/
cd aom
# TODO find stable version
cd ../
fi
if [ ! -d "SVT-AV1" ]; then
git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git
cd SVT-AV1
# TODO find stable version
cd ../
fi
if [ ! -d "SVT-VP9" ]; then
git clone https://github.com/OpenVisualCloud/SVT-VP9.git
cd SVT-VP9
# TODO find stable version
cd ../
fi
if [ ! -d "dav1d" ]; then
git clone https://code.videolan.org/videolan/dav1d.git
cd dav1d
# TODO find stable version
cd ../
fi
if [ ! -d "rav1e" ]; then
sudo cargo install cargo-c || echo "Already installed cargo-c"
git clone https://github.com/xiph/rav1e.git
cd rav1e
# TODO find stable version
cd ../
fi
if [ ! -d "FFmpeg" ]; then
git clone https://git.ffmpeg.org/ffmpeg.git FFmpeg
cd FFmpeg
git checkout d99f3dc6b211509d9f6bbb82bbb59bff86a9e3a5
cat ../ffmpeg4_modifications.diff | patch -p1
cd ../
fi
if [ ! -d "vmaf" ]; then
git clone -b v1.3.15 https://github.com/Netflix/vmaf.git vmaf
#if [ ! -f /usr/include/stdatomic.h ]; then
#sudo wget https://gist.githubusercontent.com/nhatminhle/5181506/raw/541482dbc61862bba8a156edaae57faa2995d791/stdatomic.h -O /usr/include/stdatomic.h
#fi
fi
# GCC 11.x install to /usr/local/
if [ ! -f "/usr/local/bin/gcc" ]; then
sudo yum install -y -q centos-release-scl
sudo yum install -y -q devtoolset-11-gcc*
fi
# requirement for x264
if [ ! -f "nasm-2.15.05.tar.bz2" ]; then
wget --no-check-certificate https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2
tar xvfj nasm-2.15.05.tar.bz2
cd nasm-2.15.05
./configure --prefix=/usr
make
sudo make install
cd ../
fi
if [ ! -d "opencv/build" ]; then
cd opencv
mkdir build
cd build
# build with only what we need
scl enable devtoolset-11 'cmake3 \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=True \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DWITH_OPENMP=OFF \
-WITH_OPENCL=OFF \
-DWITH_IPP=OFF \
-DBUILD_EXAMPLES=OFF \
-DWITH_FFMPEG=OFF -DWITH_JASPER=OFF -DWITH_PNG=OFF \
-DBUILD_opencv_python=OFF \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-DOPENCV_GENERATE_PKGCONFIG=True \
-DBUILD_opencv_core=ON \
-DBUILD_opencv_imgproc=ON \
-DBUILD_opencv_img_hash=ON \
-DBUILD_opencv_imgcodecs=ON \
-DBUILD_opencv_highgui=ON \
-DBUILD_opencv_aruco=OFF \
-DBUILD_opencv_bgsegm=OFF \
-DBUILD_opencv_bioinspired=OFF \
-DBUILD_opencv_calib3d=OFF \
-DBUILD_opencv_ccalib=OFF \
-DBUILD_opencv_datasets=OFF \
-DBUILD_opencv_dnn=OFF \
-DBUILD_opencv_dnn_objdetect=OFF \
-DBUILD_opencv_dpm=OFF \
-DBUILD_opencv_face=OFF \
-DBUILD_opencv_features2d=OFF \
-DBUILD_opencv_flann=OFF \
-DBUILD_opencv_fuzzy=OFF \
-DBUILD_opencv_gapi=OFF \
-DBUILD_opencv_hfs=OFF \
-DBUILD_opencv_line_descriptor=OFF \
-DBUILD_opencv_ml=OFF \
-DBUILD_opencv_objdetect=OFF \
-DBUILD_opencv_optflow=OFF \
-DBUILD_opencv_phase_unwrapping=OFF \
-DBUILD_opencv_photo=OFF \
-DBUILD_opencv_plot=OFF \
-DBUILD_opencv_python2=OFF \
-DBUILD_opencv_quality=OFF \
-DBUILD_opencv_reg=OFF \
-DBUILD_opencv_rgbd=OFF \
-DBUILD_opencv_saliency=OFF \
-DBUILD_opencv_shape=OFF \
-DBUILD_opencv_stereo=OFF \
-DBUILD_opencv_stitching=OFF \
-DBUILD_opencv_structured_light=OFF \
-DBUILD_opencv_superres=OFF \
-DBUILD_opencv_surface_matching=OFF \
-DBUILD_opencv_text=OFF \
-DBUILD_opencv_tracking=OFF \
-DBUILD_opencv_ts=OFF \
-DBUILD_opencv_video=OFF \
-DBUILD_opencv_videoio=OFF \
-DBUILD_opencv_videostab=OFF \
-DBUILD_opencv_xfeatures2d=OFF \
-DBUILD_opencv_ximgproc=OFF \
-DBUILD_opencv_xobjdetect=OFF \
-DBUILD_opencv_xphoto=OFF \
..'
# build opencv
scl enable devtoolset-11 'make -j$(nproc)'
# install opencv
sudo make install
# For some reason OpenCV3 doesn't create this link
if [ ! -e /usr/include/opencv2 -a -d /usr/include/opencv4 ]; then
sudo ln -s /usr/include/opencv4/opencv2/ /usr/include/
fi
sudo ldconfig
cd ../../
fi
## Setup x264
if [ ! -f /usr/lib/libx264.a ]; then
scl enable devtoolset-11 'make x264lib'
sudo ldconfig
fi
## Setup VMAF
if [ ! -f /usr/local/lib/libvmaf.a ]; then
scl enable devtoolset-11 'make vmaflib'
sudo ln -s /usr/local/lib/pkgconfig/libvmaf.pc /usr/share/pkgconfig/
fi
## setup dav1d
if [ ! -f /usr/local/bin/dav1d ]; then
#make dav1dlib
#sudo ln -s /usr/local/lib64/pkgconfig/dav1d.pc /usr/share/pkgconfig
sudo ldconfig
fi
## Setup VPX
if [ ! -f /usr/lib/libvpx.a ]; then
scl enable devtoolset-11 'make vpxlib'
sudo ldconfig
fi
## Setup AOM AV1
if [ ! -f /usr/lib/libaom.so ]; then
scl enable devtoolset-11 'make aomlib'
sudo ln -s /usr/lib/pkgconfig/aom.pc /usr/share/pkgconfig/
sudo ldconfig
fi
# Setup SVT-AV1
if [ ! -f "/usr/local/lib/pkgconfig/SvtAv1Dec.pc" ]; then
cd SVT-AV1/Build && \
scl enable devtoolset-11 'cmake3 .. -G"Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-I/usr/local/include -L/usr/local/lib" \
-DCMAKE_C_FLAGS="-I/usr/local/include -L/usr/local/lib" \
-DCMAKE_CXX_COMPILER=$(which g++) \
-DCMAKE_CC_COMPILER=$(which gcc) \
-DCMAKE_C_COMPILER=$(which gcc)' && \
scl enable devtoolset-11 'make -j$(nproc)' && \
sudo make install
cd ../../
sudo cp -f SVT-AV1/Build/SvtAv1Enc.pc /usr/share/pkgconfig/
sudo cp -f SVT-AV1/Build/SvtAv1Dec.pc /usr/share/pkgconfig/
fi
# Setup SVT-VP9
if [ ! -f "/usr/local/lib/pkgconfig/SvtVp9Enc.pc" ]; then
cd SVT-VP9/Build && \
scl enable devtoolset-11 'cmake3 .. -G"Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-I/usr/local/include -L/usr/local/lib" \
-DCMAKE_C_FLAGS="-I/usr/local/include -L/usr/local/lib" \
-DCMAKE_CXX_COMPILER=$(which g++) \
-DCMAKE_CC_COMPILER=$(which gcc) \
-DCMAKE_C_COMPILER=$(which gcc)' && \
scl enable devtoolset-11 'make -j$(nproc)' && \
sudo make install
cd ../../
sudo cp -f SVT-VP9/Build/SvtVp9Enc.pc /usr/share/pkgconfig/
fi
## Setup rav1e AV1
if [ ! -f /usr/local/lib/librav1e.a ]; then
#make rav1elib
#sudo ln -s /usr/local/lib/pkgconfig/rav1e.pc /usr/share/pkgconfig/
# CentOS doesn't include /usr/local/lib by default
#sudo touch /etc/ld.so.conf.d/local.conf
#sudo echo "/usr/local/lib" >> /etc/ld.so.conf.d/local.conf
#sudo echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf
sudo ldconfig
fi
## Setup FFmpeg
if [ ! -f FFmpeg/ffmpeg ]; then
scl enable devtoolset-11 'make ffmpegbin'
fi
# build tools
scl enable devtoolset-11 'make reference'
echo
echo "To install FFmpeg into /usr/bin/ffmpeg type: 'make install'"
echo "./FFmpeg/ffmpeg can be copied where you want also"