Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
329 lines (299 loc) · 11.1 KB
/
Copy pathDockerfile
File metadata and controls
329 lines (299 loc) · 11.1 KB
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
# Build stage
FROM oven/bun:1 AS builder
WORKDIR /app
COPY package.json ./
RUN bun install
COPY src/ ./src/
COPY public/ ./public/
RUN bun build src/index.ts --outfile rabbit-encoder --target bun --compile --production
# Runtime stage
FROM debian:testing-slim
USER root
ENV DEBIAN_FRONTEND=noninteractive
ENV RUSTICL_ENABLE=radeonsi,iris,nouveau
ENV OCL_ICD_VENDORS=/etc/OpenCL/vendors
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
# Base packages
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gpgv \
&& rm -rf /var/lib/apt/lists/*
# Install deb-multimedia keyring
RUN curl -fsSLo /tmp/deb-multimedia-keyring.deb \
https://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2024.9.1_all.deb \
&& dpkg -i /tmp/deb-multimedia-keyring.deb \
&& rm -f /tmp/deb-multimedia-keyring.deb
RUN cat >/etc/apt/sources.list.d/dmo.sources <<'EOF'
Types: deb
URIs: https://www.deb-multimedia.org
Suites: forky
Components: main non-free
Signed-By: /usr/share/keyrings/deb-multimedia-keyring.pgp
Enabled: yes
EOF
# Runtime packages
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
python3-venv \
python3-dev \
libpython3-dev \
ffmpeg \
mediainfo \
opus-tools \
mkvtoolnix \
zstd \
7zip \
\
# OpenCL
ocl-icd-libopencl1 \
mesa-opencl-icd \
clinfo \
\
# Vulkan / Mesa
libvulkan1 \
mesa-vulkan-drivers \
vulkan-tools \
\
# Common custom-FFmpeg runtime dependencies
libaom3 \
libaribb24-0t64 \
libass9 \
libbluray4 \
libbs2b0 \
libcaca0 \
libcdio-cdda2t64 \
libcdio-paranoia2t64 \
libchromaprint1 \
libcodec2-1.2 \
libdav1d7 \
libdavs2-16 \
libdc1394-25 \
libdrm2 \
libdvdnav4 \
libdvdread8t64 \
libfdk-aac2 \
flite \
libflite1 \
libfontconfig1 \
libfreetype6 \
libfribidi0 \
libgcrypt20 \
libgme0 \
libgsm1 \
libharfbuzz0b \
libiec61883-0 \
libavc1394-0 \
libraw1394-11 \
libilbc3 \
libjack-jackd2-0 \
libjxl0.11 \
libklvanc0 \
libkvazaar7 \
libmp3lame0 \
libmysofa1 \
libopencore-amrnb0 \
libopencore-amrwb0 \
libopenh264-8 \
libopenjp2-7 \
libopenmpt0t64 \
libopus0 \
libplacebo360 \
libpulse0 \
librabbitmq4 \
librist4 \
librsvg2-2 \
librubberband3 \
libshine3 \
libsmbclient0 \
libsnappy1v5 \
libsoxr0 \
libspeex1 \
libsrt1.5-openssl \
libsvtav1enc4 \
libtesseract5 \
libtwolame0 \
libva2 \
libvdpau1 \
libvidstab1.2 \
libvmaf3 \
libvo-amrwbenc0 \
libvorbis0a \
libvorbisenc2 \
libvpl2 \
libsvtvp9enc1 \
libwebp7 \
libwebpmux3 \
libx264-165 \
libx265-217 \
libxavs2-13 \
libxvidcore4 \
libzimg2 \
libzmq5 \
libzvbi0t64 \
liblilv-0-0 \
libopenal1 \
libssl3t64 \
libgl1 \
libegl1 \
libgles2 \
libglu1-mesa \
&& rm -f /etc/OpenCL/vendors/mesa.icd \
&& rm -rf /var/lib/apt/lists/*
# Create venv, install vsrepo, and symlink it for convenience
RUN python3 -m venv /opt/vs-venv \
&& /opt/vs-venv/bin/pip install --no-cache-dir --upgrade pip setuptools wheel \
&& /opt/vs-venv/bin/pip install --no-cache-dir \
VapourSynth \
vsrepo \
vsjetpack \
vstools \
vsutil \
vapoursynth-adaptivegrain \
vapoursynth-akarin \
vapoursynth-awarp \
vapoursynth-resize2 \
vapoursynth-vszip \
vapoursynth-zsmooth \
vapoursynth-mvtools \
vapoursynth-eedi3 \
vapoursynth-znedi3 \
vapoursynth-descale \
vapoursynth-deblock \
vapoursynth-edgemasks \
vapoursynth-hysteresis \
ffms2 \
fonttools \
&& /opt/vs-venv/bin/vapoursynth config \
&& ln -sf /opt/vs-venv/bin/python /usr/local/bin/python \
&& ln -sf /opt/vs-venv/bin/python3 /usr/local/bin/python3 \
&& ln -sf /opt/vs-venv/bin/vapoursynth /usr/local/bin/vapoursynth \
&& ln -sf /opt/vs-venv/bin/vspipe /usr/local/bin/vspipe \
&& ln -sf /opt/vs-venv/bin/vsrepo /usr/local/bin/vsrepo
# Use the venv's vsrepo to install required scripts
RUN mkdir -p /root/.config/vsrepo \
&& vsrepo update \
&& vsrepo install ffms2 fmtc
# av-denoise (GPU denoisers behind the avd-* denoise engines). Self-contained binary.
ARG AV_DENOISE_VERSION=0.6.1
ARG AV_DENOISE_SHA256=b2ee1d2009c20e5d26e7e1e6b572b617fd8b93165f3bcc789cd16440386c3df6
RUN curl -fsSL --retry 3 --connect-timeout 20 --max-time 300 \
"https://github.com/ChillFish8/av-denoise/releases/download/v${AV_DENOISE_VERSION}/av-denoise-linux-x86.tar.gz" \
-o /tmp/av-denoise.tar.gz \
&& echo "${AV_DENOISE_SHA256} /tmp/av-denoise.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/av-denoise.tar.gz -C /usr/local/bin av-denoise \
&& rm -f /tmp/av-denoise.tar.gz \
&& chmod +x /usr/local/bin/av-denoise \
&& av-denoise --version
ENV AV_DENOISE_COMPILATION_CACHE=/config/vapoursynth/av-denoise-cache
# Make the venv's Python the default for any 'python3' call
ENV PATH="/opt/vs-venv/bin:${PATH}"
COPY fonts/ /app/fonts/
COPY vapoursynth/ /app/vapoursynth/
# Download all binaries from CDN
ARG CDN_BASE="https://cdn.rabbit-company.com/rabbit-encoder/binaries"
RUN mkdir -p /opt/binaries/x86_64_v2 /opt/binaries/x86_64_v3 /opt/binaries/x86_64_v4 \
&& curl -fsSL --retry 2 "${CDN_BASE}/language-detector" -o /opt/binaries/language-detector \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v2/SVT-AV1-Essential" -o /opt/binaries/x86_64_v2/SVT-AV1-Essential \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v3/SVT-AV1-Essential" -o /opt/binaries/x86_64_v3/SVT-AV1-Essential \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v4/SVT-AV1-Essential" -o /opt/binaries/x86_64_v4/SVT-AV1-Essential \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v2/SVT-AV1-HDR" -o /opt/binaries/x86_64_v2/SVT-AV1-HDR \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v3/SVT-AV1-HDR" -o /opt/binaries/x86_64_v3/SVT-AV1-HDR \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v4/SVT-AV1-HDR" -o /opt/binaries/x86_64_v4/SVT-AV1-HDR \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v2/SVT-AV1-5FISH" -o /opt/binaries/x86_64_v2/SVT-AV1-5FISH \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v3/SVT-AV1-5FISH" -o /opt/binaries/x86_64_v3/SVT-AV1-5FISH \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v4/SVT-AV1-5FISH" -o /opt/binaries/x86_64_v4/SVT-AV1-5FISH \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v2/SVT-AV1-Tritium" -o /opt/binaries/x86_64_v2/SVT-AV1-Tritium \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v3/SVT-AV1-Tritium" -o /opt/binaries/x86_64_v3/SVT-AV1-Tritium \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v4/SVT-AV1-Tritium" -o /opt/binaries/x86_64_v4/SVT-AV1-Tritium \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v2/ffmpeg.tar.zst" -o /opt/binaries/x86_64_v2/ffmpeg.tar.zst \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v3/ffmpeg.tar.zst" -o /opt/binaries/x86_64_v3/ffmpeg.tar.zst \
&& curl -fsSL --retry 2 "${CDN_BASE}/x86_64_v4/ffmpeg.tar.zst" -o /opt/binaries/x86_64_v4/ffmpeg.tar.zst \
# Make encoder binaries executable
&& chmod +x \
/opt/binaries/language-detector \
/opt/binaries/x86_64_v2/SVT-AV1-Essential \
/opt/binaries/x86_64_v3/SVT-AV1-Essential \
/opt/binaries/x86_64_v4/SVT-AV1-Essential \
/opt/binaries/x86_64_v2/SVT-AV1-HDR \
/opt/binaries/x86_64_v3/SVT-AV1-HDR \
/opt/binaries/x86_64_v4/SVT-AV1-HDR \
/opt/binaries/x86_64_v2/SVT-AV1-5FISH \
/opt/binaries/x86_64_v3/SVT-AV1-5FISH \
/opt/binaries/x86_64_v4/SVT-AV1-5FISH \
/opt/binaries/x86_64_v2/SVT-AV1-Tritium \
/opt/binaries/x86_64_v3/SVT-AV1-Tritium \
/opt/binaries/x86_64_v4/SVT-AV1-Tritium \
# Extract FFmpeg tarballs
&& mkdir -p /opt \
&& tar --zstd -xpf /opt/binaries/x86_64_v2/ffmpeg.tar.zst -C /opt \
&& tar --zstd -xpf /opt/binaries/x86_64_v3/ffmpeg.tar.zst -C /opt \
&& tar --zstd -xpf /opt/binaries/x86_64_v4/ffmpeg.tar.zst -C /opt \
&& chmod +x \
/opt/ffmpeg-x86-64-v2/bin/ffmpeg \
/opt/ffmpeg-x86-64-v2/bin/ffprobe \
/opt/ffmpeg-x86-64-v3/bin/ffmpeg \
/opt/ffmpeg-x86-64-v3/bin/ffprobe \
/opt/ffmpeg-x86-64-v4/bin/ffmpeg \
/opt/ffmpeg-x86-64-v4/bin/ffprobe
# Verify all custom FFmpeg builds can resolve shared libraries.
RUN set -eux; \
for level in x86-64-v2 x86-64-v3 x86-64-v4; do \
echo "Checking /opt/ffmpeg-$level/bin/ffmpeg"; \
LD_LIBRARY_PATH="/opt/ffmpeg-$level/lib" ldd "/opt/ffmpeg-$level/bin/ffmpeg" | tee "/tmp/ldd-ffmpeg-$level.txt"; \
! grep -q "not found" "/tmp/ldd-ffmpeg-$level.txt"; \
echo "Checking /opt/ffmpeg-$level/bin/ffprobe"; \
LD_LIBRARY_PATH="/opt/ffmpeg-$level/lib" ldd "/opt/ffmpeg-$level/bin/ffprobe" | tee "/tmp/ldd-ffprobe-$level.txt"; \
! grep -q "not found" "/tmp/ldd-ffprobe-$level.txt"; \
done
# regrain measures film grain and writes it into the AV1 encode. It is a static binary
# and calls the ffmpeg and ffprobe that the entrypoint links into /usr/local/bin.
ARG REGRAIN_VERSION=0.5.0
ARG REGRAIN_SHA256=687d33138f59cc549d15fe4944769c15181dca5c85d173b096b577387a180392
RUN curl -fsSL --retry 3 --connect-timeout 20 --max-time 300 \
"https://github.com/Rabbit-Company/regrain/releases/download/v${REGRAIN_VERSION}/regrain-v${REGRAIN_VERSION}-linux-x86_64-v2.tar.gz" \
-o /tmp/regrain.tar.gz \
&& echo "${REGRAIN_SHA256} /tmp/regrain.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/regrain.tar.gz -C /tmp \
&& install -m 755 "/tmp/regrain-v${REGRAIN_VERSION}-linux-x86_64-v2/regrain" /usr/local/bin/regrain \
&& rm -rf /tmp/regrain.tar.gz "/tmp/regrain-v${REGRAIN_VERSION}-linux-x86_64-v2" \
&& regrain --version
# retone measures HDR10+ metadata and writes it into the AV1 encode. It is a static binary
# and calls the ffmpeg and ffprobe that the entrypoint links into /usr/local/bin.
ARG RETONE_VERSION=0.1.3
ARG RETONE_SHA256=281b69dc945dbb170eb9a4f30994134df81ffe3c1e51d2811ee1e48dc043d021
RUN curl -fsSL --retry 3 --connect-timeout 20 --max-time 300 \
"https://github.com/Rabbit-Company/retone/releases/download/v${RETONE_VERSION}/retone-v${RETONE_VERSION}-linux-x86_64-v2.tar.gz" \
-o /tmp/retone.tar.gz \
&& echo "${RETONE_SHA256} /tmp/retone.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/retone.tar.gz -C /tmp \
&& install -m 755 "/tmp/retone-v${RETONE_VERSION}-linux-x86_64-v2/retone" /usr/local/bin/retone \
&& rm -rf /tmp/retone.tar.gz "/tmp/retone-v${RETONE_VERSION}-linux-x86_64-v2" \
&& retone --version
# rabbit-denoise removes film grain on the GPU, through Vulkan, behind the rabbit-denoise denoise engine.
# It links glibc and loads the Vulkan driver at run time.
ARG RABBIT_DENOISE_VERSION=0.1.11
ARG RABBIT_DENOISE_SHA256=a5fd440611c7f1c7de9b620aecca23decc26094e316068e37ba8bac9ebed063f
RUN curl -fsSL --retry 3 --connect-timeout 20 --max-time 300 \
"https://github.com/Rabbit-Company/rabbit-denoise/releases/download/v${RABBIT_DENOISE_VERSION}/rabbit-denoise-v${RABBIT_DENOISE_VERSION}-linux-x86_64-v2.tar.gz" \
-o /tmp/rabbit-denoise.tar.gz \
&& echo "${RABBIT_DENOISE_SHA256} /tmp/rabbit-denoise.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/rabbit-denoise.tar.gz -C /tmp \
&& install -m 755 "/tmp/rabbit-denoise-v${RABBIT_DENOISE_VERSION}-linux-x86_64-v2/rabbit-denoise" /usr/local/bin/rabbit-denoise \
&& rm -rf /tmp/rabbit-denoise.tar.gz "/tmp/rabbit-denoise-v${RABBIT_DENOISE_VERSION}-linux-x86_64-v2" \
&& rabbit-denoise --version
# Entrypoint
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Auto-Boost-Essential script
RUN mkdir -p /opt/Auto-Boost-Essential
COPY scripts/Auto-Boost-Essential.py /opt/Auto-Boost-Essential/
# Application
WORKDIR /app
COPY --from=builder /app/rabbit-encoder /app/
RUN mkdir -p /data/input /data/output /data/temp
EXPOSE 3000
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/app/rabbit-encoder"]