Merge d3254e5c82 into 393441faa1
This commit is contained in:
commit
fcb170f055
2 changed files with 134 additions and 7 deletions
100
Dockerfile
100
Dockerfile
|
|
@ -41,6 +41,59 @@ COPY . .
|
|||
# ENV NODE_ENV=production
|
||||
RUN bun run build
|
||||
|
||||
# https://github.com/linuxserver/docker-ffmpeg/blob/master/Dockerfile#L968-L1012
|
||||
FROM lscr.io/linuxserver/ffmpeg:8.0.1 AS buildstage
|
||||
RUN \
|
||||
echo "**** arrange files ****" && \
|
||||
mkdir -p \
|
||||
/buildout/usr/local/bin \
|
||||
/buildout/usr/local/etc/fonts \
|
||||
/buildout/usr/local/lib/libmfx-gen \
|
||||
/buildout/usr/local/lib/mfx \
|
||||
/buildout/usr/local/lib/x86_64-linux-gnu/dri \
|
||||
/buildout/usr/local/share/vulkan \
|
||||
/buildout/usr/share/fonts \
|
||||
/buildout/usr/share/libdrm \
|
||||
/buildout/etc/OpenCL/vendors && \
|
||||
# changed https://github.com/linuxserver/docker-ffmpeg/blob/master/Dockerfile#L992-L994
|
||||
cp \
|
||||
/usr/local/bin/ffmpeg \
|
||||
/buildout/usr/local/bin && \
|
||||
cp \
|
||||
/usr/local/bin/ffprobe \
|
||||
/buildout/usr/local/bin && \
|
||||
cp -a \
|
||||
/usr/local/etc/fonts/* \
|
||||
/buildout/usr/local/etc/fonts/ && \
|
||||
cp -a \
|
||||
/usr/local/lib/lib*so* \
|
||||
/buildout/usr/local/lib/ && \
|
||||
cp -a \
|
||||
/usr/local/lib/libmfx-gen/*.so \
|
||||
/buildout/usr/local/lib/libmfx-gen/ && \
|
||||
cp -a \
|
||||
/usr/local/lib/mfx/*.so \
|
||||
/buildout/usr/local/lib/mfx/ && \
|
||||
cp -a \
|
||||
/usr/local/lib/x86_64-linux-gnu/lib*so* \
|
||||
/buildout/usr/local/lib/x86_64-linux-gnu/ && \
|
||||
cp -a \
|
||||
/usr/local/lib/x86_64-linux-gnu/dri/* \
|
||||
/buildout/usr/local/lib/x86_64-linux-gnu/dri/ && \
|
||||
# removed https://github.com/linuxserver/docker-ffmpeg/blob/master/Dockerfile#L992-L994
|
||||
cp -a \
|
||||
/usr/share/libdrm/amdgpu.ids \
|
||||
/buildout/usr/share/libdrm/ && \
|
||||
cp -a \
|
||||
/usr/share/fonts/* \
|
||||
/buildout/usr/share/fonts/ && \
|
||||
cp -a \
|
||||
/usr/local/share/vulkan/* \
|
||||
/buildout/usr/local/share/vulkan/ && \
|
||||
echo \
|
||||
'libnvidia-opencl.so.1' > \
|
||||
/buildout/etc/OpenCL/vendors/nvidia.icd
|
||||
|
||||
# copy production dependencies and source code into final image
|
||||
FROM base AS release
|
||||
|
||||
|
|
@ -51,7 +104,6 @@ RUN apt-get update && apt-get install -y \
|
|||
dasel \
|
||||
dcraw \
|
||||
dvisvgm \
|
||||
ffmpeg \
|
||||
ghostscript \
|
||||
graphicsmagick \
|
||||
imagemagick-7.q16 \
|
||||
|
|
@ -83,6 +135,52 @@ RUN apt-get update && apt-get install -y \
|
|||
&& pipx install "markitdown[all]" \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=buildstage /buildout/ /
|
||||
|
||||
ARG DEBIAN_FRONTEND="noninteractive"
|
||||
|
||||
# https://github.com/linuxserver/docker-ffmpeg/blob/master/Dockerfile#L1023-L1027
|
||||
# hardware env
|
||||
ENV \
|
||||
LIBVA_DRIVERS_PATH="/usr/local/lib/x86_64-linux-gnu/dri" \
|
||||
LD_LIBRARY_PATH="/usr/local/lib" \
|
||||
NVIDIA_DRIVER_CAPABILITIES="compute,video,utility" \
|
||||
NVIDIA_VISIBLE_DEVICES="all"
|
||||
|
||||
# install additional dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# start https://github.com/linuxserver/docker-ffmpeg/blob/master/Dockerfile#L1033-L1058
|
||||
libasound2t64 \
|
||||
libedit2 \
|
||||
libelf1 \
|
||||
libexpat1 \
|
||||
libglib2.0-0 \
|
||||
libgomp1 \
|
||||
libllvm18 \
|
||||
libpciaccess0 \
|
||||
libv4l-0 \
|
||||
libwayland-client0 \
|
||||
libx11-6 \
|
||||
libx11-xcb1 \
|
||||
libxcb-dri2-0 \
|
||||
libxcb-dri3-0 \
|
||||
libxcb-present0 \
|
||||
libxcb-randr0 \
|
||||
libxcb-shape0 \
|
||||
libxcb-shm0 \
|
||||
libxcb-sync1 \
|
||||
libxcb-xfixes0 \
|
||||
libxcb1 \
|
||||
libxext6 \
|
||||
libxfixes3 \
|
||||
libxshmfence1 \
|
||||
libxml2 \
|
||||
ocl-icd-libopencl1 && \
|
||||
echo "**** quick test ffmpeg ****" && \
|
||||
ldd /usr/local/bin/ffmpeg && \
|
||||
/usr/local/bin/ffmpeg -version
|
||||
# finish https://github.com/linuxserver/docker-ffmpeg/blob/master/Dockerfile#L1033-L1058
|
||||
|
||||
# Add pipx bin directory to PATH
|
||||
ENV PATH="/root/.local/bin:${PATH}"
|
||||
|
||||
|
|
|
|||
|
|
@ -708,10 +708,26 @@ export async function convert(
|
|||
message = "Done: resized to 256x256";
|
||||
}
|
||||
|
||||
// Parse FFMPEG_ARGS environment variable into array
|
||||
var ffmpegArgs = process.env.FFMPEG_ARGS ? process.env.FFMPEG_ARGS.split(/\s+/) : [];
|
||||
const ffmpegOutputArgs = process.env.FFMPEG_OUTPUT_ARGS
|
||||
? process.env.FFMPEG_OUTPUT_ARGS.split(/\s+/)
|
||||
: [];
|
||||
|
||||
// Check for hardware acceleration flag
|
||||
const has_hwa = process.env.FFMPEG_ARGS?.includes('-hwaccel');
|
||||
|
||||
// Determine location in array index
|
||||
const loc_hwa = ffmpegArgs.indexOf('-hwaccel');
|
||||
|
||||
// Get the hardware acceleration type if present
|
||||
// qsv, cuda, etc.
|
||||
const which_hwa = has_hwa ? ffmpegArgs[loc_hwa+1] : "";
|
||||
|
||||
if (convertTo.split(".").length > 1) {
|
||||
// Support av1.mkv and av1.mp4 and h265.mp4 etc.
|
||||
const split = convertTo.split(".");
|
||||
const codec_short = split[0];
|
||||
const codec_short = has_hwa ? split[0]+"_"+which_hwa : split[0];
|
||||
|
||||
switch (codec_short) {
|
||||
case "av1":
|
||||
|
|
@ -726,14 +742,27 @@ export async function convert(
|
|||
case "h266":
|
||||
extraArgs.push("-c:v", "libx266");
|
||||
break;
|
||||
case "h264_qsv":
|
||||
extraArgs.push("-c:v", "h264_qsv");
|
||||
break;
|
||||
case "h265_qsv":
|
||||
extraArgs.push("-c:v", "hevc_qsv");
|
||||
break;
|
||||
case "h264_cuda":
|
||||
extraArgs.push("-c:v", "h264_nvenc");
|
||||
break;
|
||||
case "h265_cuda":
|
||||
extraArgs.push("-c:v", "hevc_nvenc");
|
||||
break;
|
||||
}
|
||||
} else if(has_hwa){
|
||||
// If hardware acceleration is specified but no codec override,
|
||||
// remove from args
|
||||
ffmpegArgs = ffmpegArgs.filter((_, i) => i !== loc_hwa && i !== loc_hwa + 1);
|
||||
}
|
||||
|
||||
// Parse FFMPEG_ARGS environment variable into array
|
||||
const ffmpegArgs = process.env.FFMPEG_ARGS ? process.env.FFMPEG_ARGS.split(/\s+/) : [];
|
||||
const ffmpegOutputArgs = process.env.FFMPEG_OUTPUT_ARGS
|
||||
? process.env.FFMPEG_OUTPUT_ARGS.split(/\s+/)
|
||||
: [];
|
||||
// Debug: print the full ffmpeg command
|
||||
console.log(`ffmpeg ${ffmpegArgs} -i filePath ${ffmpegOutputArgs} ${extraArgs} ${targetPath}`)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
execFile(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue