Skip to content

Commit 94b28e1

Browse files
committed
add ffmpeg:7.0.2
1 parent c4a98f1 commit 94b28e1

File tree

7 files changed

+237
-155
lines changed

7 files changed

+237
-155
lines changed

.github/workflows/ffmpeg-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
if: startsWith(github.ref, 'refs/tags/v')
1313
strategy:
1414
matrix:
15-
ffmpeg: ["6.0", "5.1.3", "4.4.4"]
15+
ffmpeg: ["7.0.2", "6.1.2", "5.1.6", "4.4.5"]
1616
flavor: [linux, windows]
1717
steps:
1818
- name: Checkout
@@ -63,4 +63,4 @@ jobs:
6363
- name: Release
6464
uses: softprops/action-gh-release@v1
6565
with:
66-
files: /tmp/artifact/**/*.tar.xz
66+
files: /tmp/artifact/**/*.tar.xz

.github/workflows/ffmpeg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
if: startsWith(github.ref, 'refs/tags/') == false && (github.event_name == 'push' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success'))
2121
strategy:
2222
matrix:
23-
ffmpeg: ["6.0", "5.1.3", "4.4.4"]
23+
ffmpeg: ["7.0.2", "6.1.2", "5.1.6", "4.4.5"]
2424
flavor: [linux, windows]
2525
steps:
2626
- name: Checkout

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax = docker/dockerfile:1.5
22

3-
ARG FFMPEG_VERSION="6.0"
3+
ARG FFMPEG_VERSION="7.0.2"
44
FROM akashisn/ffmpeg:${FFMPEG_VERSION} AS ffmpeg-linux-image
55
FROM ghcr.io/akashisn/ffmpeg-windows:${FFMPEG_VERSION} AS ffmpeg-windows-image
66

nonfree.Dockerfile

Lines changed: 63 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,81 @@
1-
# syntax = docker/dockerfile:1.3-labs
1+
# syntax = docker/dockerfile:1.5
22

3+
ARG FFMPEG_VERSION="7.0.2"
34
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
57

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
912

1013
SHELL ["/bin/bash", "-e", "-c"]
1114
ENV DEBIAN_FRONTEND=noninteractive
1215
ENV NVIDIA_VISIBLE_DEVICES all
1316
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video
1417

15-
# Install build tools
18+
# Install ca-certificates
1619
RUN <<EOT
20+
apt-get update
21+
apt-get install -y ca-certificates
1722
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
1928
apt-get update
2029
apt-get install -y \
30+
autopoint \
31+
bc \
2132
build-essential \
2233
clang \
34+
cmake \
2335
curl \
36+
gettext \
37+
git \
38+
git-lfs \
39+
gperf \
2440
libtool \
41+
lzip \
2542
make \
43+
meson \
2644
mingw-w64 \
2745
mingw-w64-tools \
2846
nasm \
2947
p7zip \
3048
pkg-config \
49+
python3 \
50+
ragel \
51+
subversion \
52+
wget \
53+
xxd \
3154
yasm
3255
EOT
3356

34-
# ffmpeg-library-build image
35-
COPY --from=ffmpeg-library-build / /
57+
# ffmpeg-library image
58+
COPY --from=ffmpeg-library / /
3659

37-
ENV TARGET_OS=${TARGET_OS} \
60+
# Environment
61+
ARG FFMPEG_VERSION
62+
ENV FFMPEG_VERSION="${FFMPEG_VERSION}" \
3863
PREFIX="/usr/local" \
3964
LDFLAGS="-L${PREFIX}/cuda/lib64" \
4065
CFLAGS="-I${PREFIX}/cuda/include" \
66+
ARTIFACT_DIR="/dist" \
67+
RUNTIME_LIB_DIR="/runtime" \
4168
WORKDIR="/workdir"
42-
4369
WORKDIR ${WORKDIR}
4470

4571
# Copy build script
4672
ADD ./scripts/*.sh ./
4773

74+
#
75+
# ffmpeg build stage
76+
#
77+
FROM cuda-build-env AS ffmpeg-build
78+
4879

4980
#
5081
# Audio
@@ -54,10 +85,10 @@ ADD ./scripts/*.sh ./
5485
ENV FDK_AAC_VERSION=2.0.2
5586
RUN <<EOT
5687
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"
5990
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
6192
EOT
6293

6394

@@ -67,95 +98,49 @@ EOT
6798

6899
# cuda-nvcc and libnpp
69100
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
72103
RUN <<EOT
73-
if [ "${HOST_TARGET}" = "x86_64-w64-mingw32" ]; then
104+
if [ "${TARGET_OS}" = "Windows" ]; then
74105
mkdir /tmp/cuda && cd /tmp/cuda
75106
7zr x /tmp/cuda_${CUDA_SDK_VERSION}_${NVIDIA_DRIVER_VERSION}_windows.exe
76107
rm /usr/local/cuda/include/npp*
77108
rm /usr/local/cuda/lib64/libnpp*
78109
cp -r libnpp/npp_dev/include ${PREFIX}
79110
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
81112
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
127114
fi
115+
sed -i -e 's/$/ --nvccflags="-gencode arch=compute_52,code=sm_52"/g' ${PREFIX}/ffmpeg_configure_options
128116
EOT
129117

130-
# Other hwaccel
131-
RUN echo -n "`cat ${PREFIX}/ffmpeg_configure_options` --enable-d3d11va --enable-dxva2" > ${PREFIX}/ffmpeg_configure_options
132-
133118

134119
#
135120
# Build ffmpeg
136121
#
137-
ARG FFMPEG_VERSION=5.0.1
138-
ENV FFMPEG_VERSION="${FFMPEG_VERSION}"
139122

140123
# Run build
141124
RUN bash ./build-ffmpeg.sh
142125

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+
143137
# Copy artifacts
144138
RUN <<EOT
145139
mkdir /build
146140
if [ "${HOST_TARGET}" = "x86_64-w64-mingw32" ]; then
147141
cp ${PREFIX}/bin/ff* /build/
148142
cp /tmp/cuda/libnpp/npp/bin/*.dll /build/
149143
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
159144
cp --archive --parents --no-dereference ${PREFIX}/run.sh /build
160145
cp --archive --parents --no-dereference ${PREFIX}/bin/ff* /build
161146
cp --archive --parents --no-dereference ${PREFIX}/configure_options /build
@@ -174,4 +159,4 @@ EOT
174159
# Final ffmpeg image
175160
FROM scratch AS ffmpeg
176161

177-
COPY --from=ffmpeg-build /build /
162+
COPY --from=ffmpeg-build /dist /

scripts/base.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,26 @@ download_and_unpack_file () {
148148
cd ${output_dir}
149149
}
150150

151+
get_latest_version() {
152+
local url=$1
153+
local prefix=$2
154+
local major_version="${3:-""}"
155+
156+
if [ -n "${major_version}" ]; then
157+
local url="${url}/${major_version}"
158+
fi
159+
160+
local version_pattern="${prefix}\K[0-9]+(\.[0-9]+)+"
161+
162+
local html_content=$(curl -sL "$url")
163+
164+
local latest_version=$(echo "$html_content" | \
165+
grep -oP $version_pattern | \
166+
sort -V | tail -n1)
167+
168+
echo "$latest_version"
169+
}
170+
151171
git_clone() {
152172
cd ${WORKDIR}
153173
local repo_url="$1"
@@ -166,6 +186,19 @@ git_clone() {
166186
cd ${to_dir}
167187
}
168188

189+
get_latest_tag() {
190+
local repo_url=$1
191+
local prefix="${2:-""}"
192+
193+
local version_pattern="^${prefix}\K[0-9]+(\.[0-9]+)+$"
194+
195+
latest_tag=$(git ls-remote --tags "$repo_url" | awk -F/ '{print $NF}' | \
196+
grep -oP "$version_pattern" | \
197+
sort -V | tail -n1)
198+
199+
echo "$latest_tag"
200+
}
201+
169202
svn_checkout() {
170203
cd ${WORKDIR}
171204
local repo_url="$1"
@@ -240,3 +273,10 @@ gen_implib () {
240273

241274
popd
242275
}
276+
277+
do_strip () {
278+
local target_dir="$1"
279+
local file_pattern="$2"
280+
281+
find ${target_dir} -type f -name ${file_pattern} -executable -exec strip --strip-debug {} \;
282+
}

scripts/build-ffmpeg.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ source ./base.sh
44
mkdir -p ${ARTIFACT_DIR}
55

66
# Build ffmpeg
7-
FFMPEG_VERSION="${FFMPEG_VERSION:-"6.0"}"
7+
FFMPEG_VERSION="${FFMPEG_VERSION:-"7.0.2"}"
88
git_clone "https://github.com/FFmpeg/FFmpeg.git" n${FFMPEG_VERSION}
99

1010
FFMPEG_LIBVPL_SUPPORT_VERSION="6.0"
11+
# Check if the current FFMPEG_VERSION is greater than to the version that supports libvpl.
1112
if [ "${FFMPEG_VERSION}" != "${FFMPEG_LIBVPL_SUPPORT_VERSION}" ]; then
1213
if [ "$(echo -e "${FFMPEG_VERSION}\n${FFMPEG_LIBVPL_SUPPORT_VERSION}" | sort -Vr | head -n 1)" == "${FFMPEG_LIBVPL_SUPPORT_VERSION}" ]; then
1314
sed -i -e "s/libvpl/libmfx/g" ${PREFIX}/ffmpeg_configure_options
@@ -55,6 +56,7 @@ esac
5556

5657
# Build
5758
do_make_and_make_install
59+
do_strip ${PREFIX}/bin "ff*"
5860

5961

6062
#

0 commit comments

Comments
 (0)