1
- # syntax = docker/dockerfile:1.3-labs
1
+ # syntax = docker/dockerfile:1.5
2
2
3
+ ARG FFMPEG_VERSION="7.0.2"
3
4
ARG TARGET_OS="linux"
4
- ARG CUDA_SDK_VERSION=11.6.0
5
+ ARG CUDA_SDK_VERSION="12.2.0"
6
+ FROM ghcr.io/akashisn/ffmpeg-library:${TARGET_OS} AS ffmpeg-library
5
7
6
- FROM ghcr.io/akashisn/ffmpeg-library-build:${TARGET_OS} AS ffmpeg-library-build
7
-
8
- FROM nvidia/cuda:${CUDA_SDK_VERSION}-devel-ubuntu20.04 AS ffmpeg-build
8
+ #
9
+ # cuda build env base image
10
+ #
11
+ FROM nvidia/cuda:${CUDA_SDK_VERSION}-devel-ubuntu22.04 AS cuda-build-env
9
12
10
13
SHELL ["/bin/bash" , "-e" , "-c" ]
11
14
ENV DEBIAN_FRONTEND=noninteractive
12
15
ENV NVIDIA_VISIBLE_DEVICES all
13
16
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video
14
17
15
- # Install build tools
18
+ # Install ca-certificates
16
19
RUN <<EOT
20
+ apt-get update
21
+ apt-get install -y ca-certificates
17
22
rm -rf /var/lib/apt/lists/*
18
- sed -i -r 's!(deb|deb-src) \S +!\1 http://jp.archive.ubuntu.com/ubuntu/!' /etc/apt/sources.list
23
+ EOT
24
+
25
+ # Install build tools
26
+ RUN <<EOT
27
+ sed -i -r 's@http://(jp.)?archive.ubuntu.com/ubuntu/@https://ftp.udx.icscoe.jp/Linux/ubuntu/@g' /etc/apt/sources.list
19
28
apt-get update
20
29
apt-get install -y \
30
+ autopoint \
31
+ bc \
21
32
build-essential \
22
33
clang \
34
+ cmake \
23
35
curl \
36
+ gettext \
37
+ git \
38
+ git-lfs \
39
+ gperf \
24
40
libtool \
41
+ lzip \
25
42
make \
43
+ meson \
26
44
mingw-w64 \
27
45
mingw-w64-tools \
28
46
nasm \
29
47
p7zip \
30
48
pkg-config \
49
+ python3 \
50
+ ragel \
51
+ subversion \
52
+ wget \
53
+ xxd \
31
54
yasm
32
55
EOT
33
56
34
- # ffmpeg-library-build image
35
- COPY --from=ffmpeg-library-build / /
57
+ # ffmpeg-library image
58
+ COPY --from=ffmpeg-library / /
36
59
37
- ENV TARGET_OS=${TARGET_OS} \
60
+ # Environment
61
+ ARG FFMPEG_VERSION
62
+ ENV FFMPEG_VERSION="${FFMPEG_VERSION}" \
38
63
PREFIX="/usr/local" \
39
64
LDFLAGS="-L${PREFIX}/cuda/lib64" \
40
65
CFLAGS="-I${PREFIX}/cuda/include" \
66
+ ARTIFACT_DIR="/dist" \
67
+ RUNTIME_LIB_DIR="/runtime" \
41
68
WORKDIR="/workdir"
42
-
43
69
WORKDIR ${WORKDIR}
44
70
45
71
# Copy build script
46
72
ADD ./scripts/*.sh ./
47
73
74
+ #
75
+ # ffmpeg build stage
76
+ #
77
+ FROM cuda-build-env AS ffmpeg-build
78
+
48
79
49
80
#
50
81
# Audio
@@ -54,10 +85,10 @@ ADD ./scripts/*.sh ./
54
85
ENV FDK_AAC_VERSION=2.0.2
55
86
RUN <<EOT
56
87
source ./base.sh
57
- download_and_unpack_file "https://download.sourceforge.net/opencore-amr /fdk-aac/fdk-aac-${FDK_AAC_VERSION}.tar.gz "
58
- do_configure
88
+ git_clone "https://github.com/mstorsjo /fdk-aac.git "
89
+ do_configure "--enable-static --disable-shared"
59
90
do_make_and_make_install
60
- echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-libfdk-aac" > ${PREFIX}/ffmpeg_configure_options
91
+ sed -i -e 's/$/ --enable-libfdk-aac/g' ${PREFIX}/ffmpeg_configure_options
61
92
EOT
62
93
63
94
67
98
68
99
# cuda-nvcc and libnpp
69
100
ARG CUDA_SDK_VERSION
70
- ARG NVIDIA_DRIVER_VERSION=511.23
71
- ADD ./cuda_${CUDA_SDK_VERSION}_${NVIDIA_DRIVER_VERSION}_windows.exe /tmp/cuda_${CUDA_SDK_VERSION}_${NVIDIA_DRIVER_VERSION}_windows.exe
101
+ # ARG NVIDIA_DRIVER_VERSION=511.23
102
+ # ADD ./cuda_${CUDA_SDK_VERSION}_${NVIDIA_DRIVER_VERSION}_windows.exe /tmp/cuda_${CUDA_SDK_VERSION}_${NVIDIA_DRIVER_VERSION}_windows.exe
72
103
RUN <<EOT
73
- if [ "${HOST_TARGET }" = "x86_64-w64-mingw32 " ]; then
104
+ if [ "${TARGET_OS }" = "Windows " ]; then
74
105
mkdir /tmp/cuda && cd /tmp/cuda
75
106
7zr x /tmp/cuda_${CUDA_SDK_VERSION}_${NVIDIA_DRIVER_VERSION}_windows.exe
76
107
rm /usr/local/cuda/include/npp*
77
108
rm /usr/local/cuda/lib64/libnpp*
78
109
cp -r libnpp/npp_dev/include ${PREFIX}
79
110
cp libnpp/npp_dev/lib/x64/* ${PREFIX}/lib/
80
- echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-cuda-nvcc" > ${PREFIX}/ffmpeg_configure_options
111
+ sed -i -e 's/$/ --enable-cuda-nvcc --enable-libnpp/g' ${PREFIX}/ffmpeg_configure_options
81
112
else
82
- echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-cuda-nvcc --enable-libnpp" > ${PREFIX}/ffmpeg_configure_options
83
- fi
84
- echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --nvccflags='-gencode arch=compute_52,code=sm_52'" > ${PREFIX}/ffmpeg_configure_options
85
- EOT
86
-
87
- # Build libmfx
88
- ADD https://github.com/lu-zero/mfx_dispatch/archive/master.tar.gz /tmp/mfx_dispatch-master.tar.gz
89
- RUN <<EOT
90
- if [ "${HOST_TARGET}" = "x86_64-w64-mingw32" ]; then
91
- source ./base.sh
92
- download_and_unpack_file "https://github.com/lu-zero/mfx_dispatch/archive/master.tar.gz"
93
- do_configure
94
- do_make_and_make_install
95
- echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-libmfx" > ${PREFIX}/ffmpeg_configure_options
96
- fi
97
- EOT
98
-
99
- # Install MediaSDK
100
- ENV INTEL_MEDIA_SDK_VERSION=21.3.5
101
- RUN <<EOT
102
- if [ "${HOST_TARGET}" != "x86_64-w64-mingw32" ]; then
103
- apt-get install -y libdrm2 libxext6 libxfixes3
104
- source ./base.sh
105
- download_and_unpack_file "https://github.com/Intel-Media-SDK/MediaSDK/releases/download/intel-mediasdk-${INTEL_MEDIA_SDK_VERSION}/MediaStack.tar.gz"
106
- cd opt/intel/mediasdk
107
- cp --archive --no-dereference include ${PREFIX}/
108
- cp --archive --no-dereference lib64/. ${PREFIX}/lib/
109
- ldconfig
110
- echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-libmfx --enable-vaapi" > ${PREFIX}/ffmpeg_configure_options
111
- fi
112
- EOT
113
-
114
-
115
- # Other hwaccel
116
- RUN <<EOT
117
- if [ "${HOST_TARGET}" = "x86_64-w64-mingw32" ]; then
118
- echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-d3d11va --enable-dxva2" > ${PREFIX}/ffmpeg_configure_options
119
- fi
120
- EOT
121
-
122
- # Remove dynamic dll
123
- RUN <<EOT
124
- if [ "${HOST_TARGET}" = "x86_64-w64-mingw32" ]; then
125
- rm /usr/x86_64-w64-mingw32/lib/libpthread.dll.a
126
- rm /usr/lib/gcc/x86_64-w64-mingw32/*/libstdc++.dll.a
113
+ sed -i -e 's/$/ --enable-cuda-nvcc --enable-libnpp/g' ${PREFIX}/ffmpeg_configure_options
127
114
fi
115
+ sed -i -e 's/$/ --nvccflags="-gencode arch=compute_52,code=sm_52"/g' ${PREFIX}/ffmpeg_configure_options
128
116
EOT
129
117
130
- # Other hwaccel
131
- RUN echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-d3d11va --enable-dxva2" > ${PREFIX}/ffmpeg_configure_options
132
-
133
118
134
119
#
135
120
# Build ffmpeg
136
121
#
137
- ARG FFMPEG_VERSION=5.0.1
138
- ENV FFMPEG_VERSION="${FFMPEG_VERSION}"
139
122
140
123
# Run build
141
124
RUN bash ./build-ffmpeg.sh
142
125
126
+ # Copy run.sh
127
+ COPY --chmod=755 <<'EOT' ${ARTIFACT_DIR}/${PREFIX}/run.sh
128
+ # !/bin/sh
129
+ export PATH=$(dirname $0)/bin:$PATH
130
+ export LD_LIBRARY_PATH=$(dirname $0)/lib:$LD_LIBRARY_PATH
131
+ export LIBVA_DRIVERS_PATH=$(dirname $0)/lib/dri
132
+ export LIBVA_DRIVER_NAME=iHD
133
+ exec $@
134
+ EOT
135
+
136
+
143
137
# Copy artifacts
144
138
RUN <<EOT
145
139
mkdir /build
146
140
if [ "${HOST_TARGET}" = "x86_64-w64-mingw32" ]; then
147
141
cp ${PREFIX}/bin/ff* /build/
148
142
cp /tmp/cuda/libnpp/npp/bin/*.dll /build/
149
143
else
150
- cat <<'EOS' > ${PREFIX}/run.sh
151
- # !/bin/sh
152
- export PATH=$(dirname $0)/bin:$PATH
153
- export LD_LIBRARY_PATH=$(dirname $0)/lib:$LD_LIBRARY_PATH
154
- export LIBVA_DRIVERS_PATH=$(dirname $0)/lib
155
- export LIBVA_DRIVER_NAME=iHD
156
- exec $@
157
- EOS
158
- chmod +x ${PREFIX}/run.sh
159
144
cp --archive --parents --no-dereference ${PREFIX}/run.sh /build
160
145
cp --archive --parents --no-dereference ${PREFIX}/bin/ff* /build
161
146
cp --archive --parents --no-dereference ${PREFIX}/configure_options /build
174
159
# Final ffmpeg image
175
160
FROM scratch AS ffmpeg
176
161
177
- COPY --from=ffmpeg-build /build /
162
+ COPY --from=ffmpeg-build /dist /
0 commit comments