-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_ffmpeg.sh
executable file
·203 lines (169 loc) · 4.9 KB
/
build_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
#!/bin/bash
set -e
ffmpeg_build=${build_dir}/ffmpeg
fate_samples=${DIR}/ffmpeg-fate-sample
# default path of ffmpeg source code
ffmpeg_src=${DIR}/../ffmpeg
do_test=0
do_install=0
skip_test_case=""
enable_asan=0
enable_opt=0
while [ $# -gt 0 ]; do
case $1 in
--help)
echo "Use --path to specify ffmpeg source directory"
echo "Use --test to run fate test"
echo "Use --install to install after build"
echo "Use --skip_test_case to skip some test cases, separated by comma"
echo "Use --enable_asan 1 to enable address sanitizer"
exit 1
;;
--path)
ffmpeg_src=$2
shift
;;
--test)
do_test=1
;;
--install)
do_install=1
;;
--skip_test_case)
skip_test_case=$2
shift
;;
--enable_asan)
enable_asan=$2
echo "enable_asan $enable_asan"
shift
;;
--enable_opt)
enable_opt=$2
echo "enable_opt $enable_opt"
shift
;;
esac
shift
done
if ! [ -d ${ffmpeg_src} ]; then
echo "Directory $ffmpeg_src not found"
exit 1
fi
source ${DIR}/env.sh
extra_config=" "
extra_ldflags=" "
extra_libs=""
extra_libs="$extra_libs -pthread"
#if which cl.exe; then
# extra_config="${extra_config} --target-os=win64 --toolchain=msvc"
#fi
if grep -q enable-libav1d ${ffmpeg_src}/configure; then
if [ -d ${install_dir}/include/av1d ]; then
extra_config="${extra_config} --enable-libav1d"
fi
fi
if pkg-config --exists vulkan; then
extra_config="${extra_config} --enable-vulkan"
#if grep -q able-libglslang ${ffmpeg_src}/configure && [ -d '/usr/local/include/glslang/Include' ]; then
# extra_config="${extra_config} --enable-libglslang"
#fi
if grep -q able-libshaderc ${ffmpeg_src}/configure && pkg-config --exists shaderc; then
extra_config="${extra_config} --enable-libshaderc"
fi
if grep -q libplacebo ${ffmpeg_src}/configure && pkg-config --exists libplacebo "libplacebo >= 4.192.0"; then
extra_config="${extra_config} --enable-libplacebo"
fi
if pkg-config --exists libdrm; then
extra_config="${extra_config} --enable-libdrm"
fi
fi
if pkg-config --exists libmfx; then
extra_config="${extra_config} --enable-libmfx"
fi
if grep -q able-libzimg ${ffmpeg_src}/configure && pkg-config --exists zimg; then
extra_config="${extra_config} --enable-libzimg"
fi
if grep -q enable-libuavs3d ${ffmpeg_src}/configure; then
extra_config="${extra_config} --enable-libuavs3d"
fi
#if grep -q enable-libvvdec ${ffmpeg_src}/configure; then
# extra_config="${extra_config} --enable-libvvdec"
#fi
if pkg-config --exists libass; then
extra_config="${extra_config} --enable-libass"
fi
if pkg-config --exists davs2; then
extra_config="${extra_config} --enable-libdavs2"
fi
#if pkg-config --exists openvino; then
# extra_config="${extra_config} --enable-libopenvino"
#fi
if pkg-config --exists fontconfig; then
extra_config="${extra_config} --enable-libfreetype --enable-libfontconfig"
fi
if pkg-config --exists harfbuzz; then
extra_config="${extra_config} --enable-libharfbuzz"
fi
if [ "$enable_asan" -eq 1 ]; then
if ${CC} -v 2>&1 |grep 'clang version' -q; then
extra_config="--toolchain=clang-asan ${extra_config}"
else
extra_config="--toolchain=gcc-asan ${extra_config}"
extra_ldflags="${extra_ldflags} -static-libasan"
fi
ffmpeg_build=${ffmpeg_build}_asan
fi
#if which nvcc; then
# extra_config="${extra_config} --enable-cuda-nvcc"
#fi
if [ "$enable_opt" -eq 0 ]; then
extra_config="${extra_config} --enable-debug --disable-optimizations"
else
ffmpeg_build=${ffmpeg_build}_opt
fi
mkdir -p $build_dir
pushd $build_dir
# allow in source build of ffmpeg with msys
if [ -z "$MSYSTEM" ]; then
# cleanup for non-msys
rm -Rf ${ffmpeg_build}
fi
mkdir -p ${ffmpeg_build}
pushd ${ffmpeg_build}
$ffmpeg_src/configure \
--prefix=$install_dir \
--cc=${CC} \
--cxx=${CXX} \
--assert-level=2 \
--extra-cflags="-I${install_dir}/include" \
--extra-ldflags="-L${install_dir}/lib ${extra_ldflags}" \
--extra-libs="-lstdc++ $extra_libs -lm" \
--pkg-config-flags='--static' \
--enable-libaom \
--enable-libvvenc \
--enable-libx264 \
--enable-libx265 \
--enable-libdav1d \
--enable-nonfree \
--enable-gpl \
--enable-version3 \
--enable-rpath \
--enable-libxml2 \
--enable-opencl \
--enable-openssl \
--disable-doc \
--samples=${fate_samples} \
--ignore-tests="${skip_test_case}" \
--disable-stripping \
${extra_config}
make -j $(nproc)
if [ "$do_test" -eq 1 ]; then
make fate-rsync -j $(nproc)
VERBOSE=1 make fate -j $(nproc)
fi
if [ "$do_install" -eq 1 ]; then
make install
fi
popd # ${ffmpeg_build}
popd