forked from jlesage/docker-handbrake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.nightly
312 lines (298 loc) · 10.2 KB
/
Dockerfile.nightly
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
#
# handbrake Dockerfile
#
# https://github.com/jlesage/docker-handbrake
#
# Pull base image.
FROM jlesage/baseimage-gui:alpine-3.8-v3.5.1
# Define software versions.
# NOTE: x264 version 20171224 is the most recent one that doesn't crash.
ARG HANDBRAKE_VERSION=1.2.0
ARG X264_VERSION=20171224
ARG LIBVA_VERSION=2.3.0
ARG INTEL_VAAPI_DRIVER_VERSION=2.3.0
ARG GMMLIB_VERSION=18.3.0
ARG INTEL_MEDIA_DRIVER_VERSION=18.3.0
ARG INTEL_MEDIA_SDK_VERSION=18.3.1
# Define software download URLs.
ARG HANDBRAKE_URL=https://download.handbrake.fr/releases/${HANDBRAKE_VERSION}/HandBrake-${HANDBRAKE_VERSION}-source.tar.bz2
ARG X264_URL=https://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-${X264_VERSION}-2245-stable.tar.bz2
ARG LIBVA_URL=https://github.com/intel/libva/releases/download/2.3.0/libva-${LIBVA_VERSION}.tar.bz2
ARG INTEL_VAAPI_DRIVER_URL=https://github.com/intel/intel-vaapi-driver/releases/download/${INTEL_VAAPI_DRIVER_VERSION}/intel-vaapi-driver-${INTEL_VAAPI_DRIVER_VERSION}.tar.bz2
ARG GMMLIB_URL=https://github.com/intel/gmmlib/archive/intel-gmmlib-${GMMLIB_VERSION}.tar.gz
ARG INTEL_MEDIA_DRIVER_URL=https://github.com/intel/media-driver/archive/intel-media-${INTEL_MEDIA_DRIVER_VERSION}.tar.gz
ARG INTEL_MEDIA_SDK_URL=https://github.com/Intel-Media-SDK/MediaSDK/archive/intel-mediasdk-${INTEL_MEDIA_SDK_VERSION}.tar.gz
# Other build arguments.
# Set to 'max' to keep debug symbols.
ARG HANDBRAKE_DEBUG_MODE=none
# Define working directory.
WORKDIR /tmp
# Compile HandBrake, libva and Intel Media SDK.
RUN \
add-pkg --virtual build-dependencies \
# build tools.
curl \
build-base \
yasm \
autoconf \
cmake \
automake \
libtool \
m4 \
patch \
coreutils \
tar \
file \
python \
linux-headers \
intltool \
git \
diffutils \
bash \
nasm \
# misc libraries
jansson-dev \
libxml2-dev \
libpciaccess-dev \
xz-dev \
# media libraries
libsamplerate-dev \
libass-dev \
# media codecs
libtheora-dev \
lame-dev \
opus-dev \
libvorbis-dev \
speex-dev \
libvpx-dev \
# gtk
gtk+3.0-dev \
dbus-glib-dev \
libnotify-dev \
libgudev-dev \
&& \
# Download x264 sources.
echo "Downloading x264 sources..." && \
mkdir x264 && \
curl -# -L ${X264_URL} | tar xj --strip 1 -C x264 && \
# Download libva sources.
echo "Downloading libva sources..." && \
mkdir libva && \
curl -# -L ${LIBVA_URL} | tar xj --strip 1 -C libva && \
# Download Intel VAAPI driver sources.
echo "Downloading Intel VAAPI driver sources..." && \
mkdir intel-vaapi-driver && \
curl -# -L ${INTEL_VAAPI_DRIVER_URL} | tar xj --strip 1 -C intel-vaapi-driver && \
# Download gmmlib sources.
echo "Downloading gmmlib sources..." && \
mkdir gmmlib && \
curl -# -L ${GMMLIB_URL} | tar xz --strip 1 -C gmmlib && \
# Download Intel Media driver.
echo "Downloading Intel Media driver sources..." && \
mkdir intel-media-driver && \
curl -# -L ${INTEL_MEDIA_DRIVER_URL} | tar xz --strip 1 -C intel-media-driver && \
# Download Intel Media SDK sources.
echo "Downloading Intel Media SDK sources..." && \
mkdir MediaSDK && \
curl -# -L ${INTEL_MEDIA_SDK_URL} | tar xz --strip 1 -C MediaSDK && \
# Download HandBrake sources.
echo "Downloading HandBrake sources..." && \
if echo "${HANDBRAKE_URL}" | grep -q '\.git$'; then \
git clone ${HANDBRAKE_URL} HandBrake && \
git -C HandBrake checkout "${HANDBRAKE_VERSION}"; \
else \
mkdir HandBrake && \
curl -# -L ${HANDBRAKE_URL} | tar xj --strip 1 -C HandBrake; \
fi && \
# Download helper.
echo "Downloading helpers..." && \
curl -# -L -o /tmp/run_cmd https://raw.githubusercontent.com/jlesage/docker-mgmt-tools/master/run_cmd && \
chmod +x /tmp/run_cmd && \
# Download patches.
echo "Downloading patches..." && \
curl -# -L -o HandBrake/A00-hb-video-preset.patch https://raw.githubusercontent.com/jlesage/docker-handbrake/master/A00-hb-video-preset.patch && \
curl -# -L -o MediaSDK/intel-media-sdk-debug-no-assert.patch https://raw.githubusercontent.com/jlesage/docker-handbrake/master/intel-media-sdk-debug-no-assert.patch && \
curl -# -L -o intel-media-driver/media-driver-c-assert-fix.patch https://raw.githubusercontent.com/jlesage/docker-handbrake/master/media-driver-c-assert-fix.patch && \
# Compile x264.
echo "Compiling x264..." && \
cd x264 && \
if [ "${HANDBRAKE_DEBUG_MODE}" = "none" ]; then \
X264_CMAKE_OPTS=--enable-strip; \
else \
X264_CMAKE_OPTS=--enable-debug; \
fi && \
./configure \
--prefix=/usr \
--enable-shared \
--enable-pic \
--disable-cli \
$X264_CMAKE_OPTS \
&& \
make -j$(nproc) install && \
cd ../ && \
# Compile libva.
echo "Compiling libva..." && \
cd libva && \
./configure \
--prefix=/usr \
--mandir=/tmp/libva-man \
--infodir=/tmp/liva-info \
--localstatedir=/var \
--enable-x11 \
--disable-glx \
--disable-wayland \
--disable-static \
--enable-shared \
--with-drivers-path=/opt/intel/mediasdk/lib64 \
&& \
make -j$(nproc) && \
make install && \
cd ../ && \
# Compile Intel VAAPI driver.
echo "Compiling Intel VAAPI driver..." && \
cd intel-vaapi-driver && \
./configure && \
make -j$(nproc) && \
make install && \
cd .. && \
# Compile Intel Media driver.
echo "Compiling Intel Media driver..." && \
add-pkg libexecinfo-dev && \
cd intel-media-driver && \
patch -p1 < media-driver-c-assert-fix.patch && \
mkdir build && cd build && \
cmake \
-Wno-dev \
-DBUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/intel/mediasdk \
-DLIBVA_DRIVERS_PATH=/opt/intel/mediasdk/lib64 \
-DINSTALL_DRIVER_SYSCONF=OFF \
-DMEDIA_RUN_TEST_SUITE=OFF \
../ && \
make -j$(nproc) && \
make install && \
cd .. && \
cd .. && \
# Compile Intel Media SDK.
echo "Compiling Intel Media SDK..." && \
cd MediaSDK && \
patch -p1 < intel-media-sdk-debug-no-assert.patch && \
mkdir build && \
cd build && \
if [ "${HANDBRAKE_DEBUG_MODE}" = "none" ]; then \
INTEL_MEDIA_SDK_BUILD_TYPE=RELEASE; \
else \
INTEL_MEDIA_SDK_BUILD_TYPE=DEBUG; \
fi && \
cmake \
-DCMAKE_BUILD_TYPE=$INTEL_MEDIA_SDK_BUILD_TYPE \
# HandBrake's libfmx is looking at /opt/intel/mediasdk/plugins for MFX plugins.
-DMFX_PLUGINS_DIR=/opt/intel/mediasdk/plugins \
-DMFX_PLUGINS_CONF_DIR=/opt/intel/mediasdk/plugins \
-DENABLE_OPENCL=OFF \
-DENABLE_X11_DRI3=OFF \
-DENABLE_WAYLAND=OFF \
-DBUILD_DISPATCHER=ON \
-DENABLE_ITT=OFF \
-DENABLE_TEXTLOG=OFF \
-DENABLE_STAT=OFF \
-DBUILD_SAMPLES=OFF \
.. && \
make -j$(nproc) install && \
cd .. && \
cd .. && \
# Compile HandBrake.
echo "Compiling HandBrake..." && \
cd HandBrake && \
patch -p1 < A00-hb-video-preset.patch && \
./configure --prefix=/usr \
--debug=$HANDBRAKE_DEBUG_MODE \
--disable-gtk-update-checks \
--enable-fdk-aac \
--enable-x265 \
--enable-qsv \
--launch-jobs=$(nproc) \
--launch \
&& \
/tmp/run_cmd -i 600 -m "HandBrake still compiling..." make --directory=build install && \
cd .. && \
# Strip symbols.
if [ "${HANDBRAKE_DEBUG_MODE}" = "none" ]; then \
find /usr/lib -type f -name "libva*.so*" -exec strip -s {} ';'; \
find /opt/intel/mediasdk -type f -name "*.so*" -exec strip -s {} ';'; \
strip -s /usr/bin/ghb; \
strip -s /usr/bin/HandBrakeCLI; \
fi && \
# Cleanup.
del-pkg build-dependencies && \
rm -r \
/usr/lib/libva*.la \
/opt/intel/mediasdk/include \
/opt/intel/mediasdk/lib64/pkgconfig \
/opt/intel/mediasdk/lib64/*.a \
/opt/intel/mediasdk/lib64/*.la \
# HandBrake already include a statically-linked version of libmfx.
/opt/intel/mediasdk/lib64/libmfx.* \
/usr/lib/pkgconfig \
/usr/include \
&& \
rm -rf /tmp/* /tmp/.[!.]*
# Install dependencies.
RUN \
add-pkg \
gtk+3.0 \
libgudev \
dbus-glib \
libnotify \
libsamplerate \
libass \
jansson \
xz \
# Media codecs:
libtheora \
lame \
opus \
libvorbis \
speex \
libvpx \
# To read encrypted DVDs
libdvdcss \
# For main, big icons:
librsvg \
# For all other small icons:
adwaita-icon-theme \
# For optical drive listing:
lsscsi \
# For watchfolder
findutils \
expect
# Adjust the openbox config.
RUN \
# Maximize only the main/initial window.
sed-patch 's/<application type="normal">/<application type="normal" title="HandBrake">/' \
/etc/xdg/openbox/rc.xml && \
# Make sure the main window is always in the background.
sed-patch '/<application type="normal" title="HandBrake">/a \ <layer>below</layer>' \
/etc/xdg/openbox/rc.xml
# Generate and install favicons.
RUN \
APP_ICON_URL=https://raw.githubusercontent.com/jlesage/docker-templates/master/jlesage/images/handbrake-icon.png && \
install_app_icon.sh "$APP_ICON_URL"
# Add files.
COPY rootfs/ /
# Set environment variables.
ENV APP_NAME="HandBrake" \
AUTOMATED_CONVERSION_PRESET="Very Fast 1080p30" \
AUTOMATED_CONVERSION_FORMAT="mp4"
# Define mountable directories.
VOLUME ["/config"]
VOLUME ["/storage"]
VOLUME ["/output"]
VOLUME ["/watch"]
# Metadata.
LABEL \
org.label-schema.name="handbrake" \
org.label-schema.description="Docker container for HandBrake" \
org.label-schema.version="unknown" \
org.label-schema.vcs-url="https://github.com/jlesage/docker-handbrake" \
org.label-schema.schema-version="1.0"