forked from dlstreamer/pipeline-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.ffmpeg.base
359 lines (292 loc) · 14.5 KB
/
Dockerfile.ffmpeg.base
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
# video_analytics_serving_ffmpeg
FROM ubuntu:18.04 AS build
WORKDIR /home
# MULTI-LICENSE DISCLAIMER
RUN echo "IMPORTANT: This script will build third party components licensed under various open source licenses into your container images. The terms under which those components may be used and distributed can be found with the license document that is provided with those components. Please familiarize yourself with those terms to ensure your distribution of those components complies with the terms of those licenses."
# COMMON BUILD TOOLS
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y -q --no-install-recommends build-essential autoconf make git wget pciutils cpio libtool lsb-release ca-certificates pkg-config bison flex libcurl4-gnutls-dev zlib1g-dev
# Install cmake
ARG CMAKE_VER=3.13.1
ARG CMAKE_REPO=https://cmake.org/files
RUN wget -O - ${CMAKE_REPO}/v${CMAKE_VER%.*}/cmake-${CMAKE_VER}.tar.gz | tar xz && \
cd cmake-${CMAKE_VER} && \
./bootstrap --prefix="/usr" --system-curl && \
make -j8 && \
make install
# Install automake, use version 1.14 on CentOS
ARG AUTOMAKE_VER=1.14
ARG AUTOMAKE_REPO=https://ftp.gnu.org/pub/gnu/automake/automake-${AUTOMAKE_VER}.tar.xz
RUN apt-get install -y -q automake
# Build NASM
ARG NASM_VER=2.13.03
ARG NASM_REPO=https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VER}/nasm-${NASM_VER}.tar.bz2
RUN wget ${NASM_REPO} && \
tar -xaf nasm* && \
cd nasm-${NASM_VER} && \
./autogen.sh && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu && \
make -j8 && \
make install
# Build YASM
RUN apt-get install yasm
# Build ogg
ARG OGG_VER=1.3.3
ARG OGG_REPO=https://downloads.xiph.org/releases/ogg/libogg-${OGG_VER}.tar.xz
RUN wget -O - ${OGG_REPO} | tar xJ && \
cd libogg-${OGG_VER} && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --enable-shared && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Build vorbis
ARG VORBIS_VER=1.3.6
ARG VORBIS_REPO=https://downloads.xiph.org/releases/vorbis/libvorbis-${VORBIS_VER}.tar.xz
RUN wget -O - ${VORBIS_REPO} | tar xJ && \
cd libvorbis-${VORBIS_VER} && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --enable-shared && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Build mp3lame
ARG MP3LAME_VER=3.100
ARG MP3LAME_REPO=https://sourceforge.net/projects/lame/files/lame/${MP3LAME_VER}/lame-${MP3LAME_VER}.tar.gz
RUN wget -O - ${MP3LAME_REPO} | tar xz && \
cd lame-${MP3LAME_VER} && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --enable-shared --enable-nasm && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Build fdk-aac
ARG FDK_AAC_VER=v0.1.6
ARG FDK_AAC_REPO=https://github.com/mstorsjo/fdk-aac/archive/${FDK_AAC_VER}.tar.gz
RUN wget -O - ${FDK_AAC_REPO} | tar xz && mv fdk-aac-${FDK_AAC_VER#v} fdk-aac && \
cd fdk-aac && \
autoreconf -fiv && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --enable-shared && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Build opus
ARG OPUS_VER=1.2.1
ARG OPUS_REPO=https://archive.mozilla.org/pub/opus/opus-${OPUS_VER}.tar.gz
RUN wget -O - ${OPUS_REPO} | tar xz && \
cd opus-${OPUS_VER} && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --enable-shared && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Build vpx
ARG VPX_VER=tags/v1.7.0
ARG VPX_REPO=https://chromium.googlesource.com/webm/libvpx.git
RUN git clone ${VPX_REPO} && \
cd libvpx && \
git checkout ${VPX_VER} && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=nasm && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Build AOM
ARG AOM_VER=b6f1767eedbaddeb1ff5aa409a710ef61078640e
ARG AOM_REPO=https://aomedia.googlesource.com/aom
RUN git clone ${AOM_REPO} && \
mkdir aom/aom_build && \
cd aom/aom_build && \
git checkout ${AOM_VER} && \
cmake -DBUILD_SHARED_LIBS=ON -DENABLE_NASM=ON -DENABLE_TESTS=OFF -DENABLE_DOCS=OFF -DCMAKE_INSTALL_PREFIX="/usr" -DLIB_INSTALL_DIR=/usr/lib/x86_64-linux-gnu .. && \
make -j8 && \
make install DESTDIR="/home/build" && \
make install
# Build x264
ARG X264_VER=stable
ARG X264_REPO=https://github.com/mirror/x264
RUN git clone ${X264_REPO} && \
cd x264 && \
git checkout ${X264_VER} && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --enable-shared && \
make -j8 && \
make install DESTDIR="/home/build" && \
make install
# Build x265
ARG X265_VER=2.9
ARG X265_REPO=https://github.com/videolan/x265/archive/${X265_VER}.tar.gz
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y -q --no-install-recommends libnuma-dev
RUN wget -O - ${X265_REPO} | tar xz && mv x265-${X265_VER} x265 && \
cd x265/build/linux && \
cmake -DBUILD_SHARED_LIBS=ON -DENABLE_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DLIB_INSTALL_DIR=/usr/lib/x86_64-linux-gnu ../../source && \
make -j8 && \
make install DESTDIR="/home/build" && \
make install
# Fetch SVT-HEVC
ARG SVT_HEVC_VER=20a47b0d904e9d99e089d93d7c33af92788cbfdb
ARG SVT_HEVC_REPO=https://github.com/intel/SVT-HEVC
RUN git clone ${SVT_HEVC_REPO} && \
cd SVT-HEVC/Build/linux && \
git checkout ${SVT_HEVC_VER} && \
mkdir -p ../../Bin/Release && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu -DCMAKE_ASM_NASM_COMPILER=yasm ../.. && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Fetch SVT-AV1
ARG SVT_AV1_VER=v0.6.0
ARG SVT_AV1_REPO=https://github.com/OpenVisualCloud/SVT-AV1
RUN git clone ${SVT_AV1_REPO} && \
cd SVT-AV1/Build/linux && \
git checkout ${SVT_AV1_VER} && \
mkdir -p ../../Bin/Release && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu -DCMAKE_ASM_NASM_COMPILER=yasm ../.. && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
#Remove build residue from SVT-AV1 build -- temp fix for bug
RUN if [ -d "build/home/" ]; then rm -rf build/home/; fi
# Fetch SVT-VP9
ARG SVT_VP9_VER=d18b4acf9139be2e83150e318ffd3dba1c432e74
ARG SVT_VP9_REPO=https://github.com/OpenVisualCloud/SVT-VP9
RUN git clone ${SVT_VP9_REPO} && \
cd SVT-VP9/Build/linux && \
git checkout ${SVT_VP9_VER} && \
mkdir -p ../../Bin/Release && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu -DCMAKE_ASM_NASM_COMPILER=yasm ../.. && \
make -j8 && \
make install DESTDIR=/home/build && \
make install
# Build DLDT-Inference Engine
ARG DLDT_VER=2019_R2
ARG DLDT_REPO=https://github.com/opencv/dldt.git
RUN apt-get -y install libusb-1.0.0-dev
RUN git clone -b ${DLDT_VER} ${DLDT_REPO} && \
cd dldt && \
git submodule init && \
git submodule update --recursive && \
cd inference-engine && \
mkdir build && \
cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/opt/intel/dldt -DLIB_INSTALL_PATH=/opt/intel/dldt -DENABLE_MKL_DNN=ON -DENABLE_CLDNN=OFF -DENABLE_SAMPLES=OFF -DENABLE_TESTS=OFF .. && \
make -j $(nproc) && \
rm -rf ../bin/intel64/Release/lib/libgtest* && \
rm -rf ../bin/intel64/Release/lib/libgmock* && \
rm -rf ../bin/intel64/Release/lib/libmock* && \
rm -rf ../bin/intel64/Release/lib/libtest*
ARG libdir=/opt/intel/dldt/inference-engine/lib/intel64
RUN mkdir -p /opt/intel/dldt/inference-engine/include && \
cp -r dldt/inference-engine/include/* /opt/intel/dldt/inference-engine/include && \
mkdir -p ${libdir} && \
cp -r dldt/inference-engine/bin/intel64/Release/lib/* ${libdir} && \
mkdir -p /opt/intel/dldt/inference-engine/src && \
cp -r dldt/inference-engine/src/* /opt/intel/dldt/inference-engine/src/ && \
mkdir -p /opt/intel/dldt/inference-engine/share && \
cp -r dldt/inference-engine/build/share/* /opt/intel/dldt/inference-engine/share/ && \
mkdir -p /opt/intel/dldt/inference-engine/external/omp/lib && \
cp -r dldt/inference-engine/temp/tbb /opt/intel/dldt/inference-engine/external/
RUN mkdir -p build/opt/intel/dldt/inference-engine/include && \
cp -r dldt/inference-engine/include/* build/opt/intel/dldt/inference-engine/include && \
mkdir -p build${libdir} && \
cp -r dldt/inference-engine/bin/intel64/Release/lib/* build${libdir} && \
mkdir -p build/opt/intel/dldt/inference-engine/src && \
cp -r dldt/inference-engine/src/* build/opt/intel/dldt/inference-engine/src/ && \
mkdir -p build/opt/intel/dldt/inference-engine/share && \
cp -r dldt/inference-engine/build/share/* build/opt/intel/dldt/inference-engine/share/ && \
mkdir -p build/opt/intel/dldt/inference-engine/external/omp/lib && \
cp -r dldt/inference-engine/temp/tbb build/opt/intel/dldt/inference-engine/external/
RUN for p in /usr /home/build/usr /opt/intel/dldt/inference-engine /home/build/opt/intel/dldt/inference-engine; do \
pkgconfiglibdir="$p/lib/x86_64-linux-gnu" && \
mkdir -p "${pkgconfiglibdir}/pkgconfig" && \
pc="${pkgconfiglibdir}/pkgconfig/dldt.pc" && \
echo "prefix=/opt" > "$pc" && \
echo "libdir=${libdir}" >> "$pc" && \
echo "includedir=/opt/intel/dldt/inference-engine/include" >> "$pc" && \
echo "" >> "$pc" && \
echo "Name: DLDT" >> "$pc" && \
echo "Description: Intel Deep Learning Deployment Toolkit" >> "$pc" && \
echo "Version: 5.0" >> "$pc" && \
echo "" >> "$pc" && \
echo "Libs: -L\${libdir} -linference_engine -linference_engine_c_wrapper" >> "$pc" && \
echo "Cflags: -I\${includedir}" >> "$pc"; \
done;
ENV InferenceEngine_DIR=/opt/intel/dldt/inference-engine/share
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/dldt/inference-engine/lib:/opt/intel/dldt/inference-engine/external/tbb/lib:${libdir}
# DLDT IE C API
ARG C_API_NAME=dldt-c_api_v1-0.1
ARG C_API_TAR_REPO=https://raw.githubusercontent.com/VCDP/FFmpeg-patch/master/thirdparty/dldt-c-api/source/${C_API_NAME}.tar.gz
RUN wget -O - ${C_API_TAR_REPO} | tar xz && \
cd ${C_API_NAME} && \
mkdir -p build && cd build && \
cmake .. && \
make -j8 && \
make install && \
cp -rf /usr/local/include/dldt/* /opt/intel/dldt/inference-engine/include && \
c_api_libdir="/usr/local/lib" && \
cp -rf ${c_api_libdir}/* ${libdir} && \
cp -rf ${c_api_libdir}/* /home/build${libdir}
#install Model Optimizer in the DLDT for Dev
# Build libjson-c
ARG LIBJSONC_VER=0.13.1-20180305
ARG LIBJSONC_REPO=https://github.com/json-c/json-c/archive/json-c-${LIBJSONC_VER}.tar.gz
RUN wget -O - ${LIBJSONC_REPO} | tar xz && \
cd json-c-json-c-${LIBJSONC_VER} && \
sh autogen.sh && \
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu && \
make -j8 && \
make install DESTDIR="/home/build" && \
make install;
# Build librdkafka
ARG LIBRDKAFKA_VER=0.11.6
ARG FILE_NAME=v${LIBRDKAFKA_VER}
ARG LIBRDKAFKA_REPO=https://github.com/edenhill/librdkafka/archive/${FILE_NAME}.tar.gz
RUN wget -O - ${LIBRDKAFKA_REPO} | tar xz && \
cd librdkafka-${LIBRDKAFKA_VER} && \
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu && \
make -j8 && \
make install DESTDIR=/home/build && \
make install;
# Fetch FFmpeg source
ARG FFMPEG_VER=n4.1
ARG FFMPEG_REPO=https://github.com/FFmpeg/FFmpeg/archive/${FFMPEG_VER}.tar.gz
ARG FFMPEG_1TN_PATCH_REPO=https://patchwork.ffmpeg.org/patch/11625/raw
ARG FFMPEG_THREAD_PATCH_REPO=https://patchwork.ffmpeg.org/patch/11035/raw
ARG FFMPEG_PATCHES_RELEASE_VER=0.1
ARG FFMPEG_PATCHES_RELEASE_URL=https://github.com/VCDP/CDN/archive/v${FFMPEG_PATCHES_RELEASE_VER}.tar.gz
ARG FFMPEG_PATCHES_PATH=/home/CDN-${FFMPEG_PATCHES_RELEASE_VER}
RUN wget -O - ${FFMPEG_PATCHES_RELEASE_URL} | tar xz
ARG FFMPEG_MA_RELEASE_VER=0.2
ARG FFMPEG_MA_RELEASE_URL=https://github.com/VCDP/FFmpeg-patch/archive/v${FFMPEG_MA_RELEASE_VER}.tar.gz
ARG FFMPEG_MA_PATH=/home/FFmpeg-patch-${FFMPEG_MA_RELEASE_VER}
RUN wget -O - ${FFMPEG_MA_RELEASE_URL} | tar xz
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y -q --no-install-recommends libass-dev libfreetype6-dev zlib1g-dev libssl-dev
RUN wget -O - ${FFMPEG_REPO} | tar xz && mv FFmpeg-${FFMPEG_VER} FFmpeg && \
cd FFmpeg && \
find ${FFMPEG_PATCHES_PATH}/FFmpeg_patches -type f -name '0001*.patch' -print0 | sort -z | xargs -t -0 -n 1 patch -p1 -i && \
wget -O - ${FFMPEG_1TN_PATCH_REPO} | patch -p1 && \
wget -O - ${FFMPEG_THREAD_PATCH_REPO} | patch -p1 && \
find ${FFMPEG_MA_PATH}/media-analytics -type f -name '*.patch' -print0 | sort -z | xargs -t -0 -n 1 patch -p1 -i;
# Patch FFmpeg source for SVT-HEVC
RUN cd /home/FFmpeg && \
patch -p1 < ../SVT-HEVC/ffmpeg_plugin/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch;
# Patch FFmpeg source for SVT-AV1
RUN cd /home/FFmpeg; \
patch -p1 < ../SVT-AV1/ffmpeg_plugin/0001-Add-ability-for-ffmpeg-to-run-svt-av1-with-svt-hevc.patch;
# Compile FFmpeg
RUN cd /home/FFmpeg && \
./configure --prefix="/usr" --libdir=/usr/lib/x86_64-linux-gnu --extra-libs="-lpthread -lm" --enable-shared --disable-xlib --disable-sdl2 --enable-openssl --disable-vaapi --disable-hwaccels --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libaom --enable-libsvthevc --enable-libsvtav1 --enable-libinference_engine --enable-librdkafka --enable-libjson_c && \
make -j8 && \
make install DESTDIR="/home/build"
# Clean up after build
RUN rm -rf /home/build/usr/include && \
rm -rf /home/build/usr/share/doc && \
rm -rf /home/build/usr/share/gtk-doc && \
rm -rf /home/build/usr/share/man && \
find /home/build -name "*.a" -exec rm -f {} \;
FROM ubuntu:18.04
LABEL Description="This is the image for DLDT and FFMPEG on Ubuntu 18.04"
LABEL Vendor="Intel Corporation"
WORKDIR /home
# Prerequisites
RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime; \
DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y -q --no-install-recommends libnuma1 libass9 libssl1.1 libpciaccess0 ; \
rm -rf /var/lib/apt/lists/*;
# Install
COPY --from=build /home/build /
ARG libdir=/opt/intel/dldt/inference-engine/lib/intel64
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/dldt/inference-engine/lib:/opt/intel/dldt/inference-engine/external/tbb/lib:${libdir}
ENV InferenceEngine_DIR=/opt/intel/dldt/inference-engine/share