Skip to content

Commit ed78a76

Browse files
committed
CI Linux FFmpeg: consolidate to a single script
in similar fashion as already done for install_sdl.sh As a bonus, we do not need to depend on whole prepare.sh for cache rebuild but only on this script, which is perhaps cleaner and may yield less rebuilds. Also prepare.sh is slightly easier.
1 parent a15d3d0 commit ed78a76

File tree

4 files changed

+129
-96
lines changed

4 files changed

+129
-96
lines changed

.github/scripts/Linux/download_build_ffmpeg.sh

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 125 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,127 @@
11
#!/bin/bash -eux
22

3-
cd /var/tmp/ffmpeg
4-
( cd libvpx && sudo make install )
5-
( cd nv-codec-headers && sudo make install )
6-
( cd aom/build && sudo cmake --install . )
7-
sudo cmake --install SVT-AV1/Build
8-
sudo cmake --install SVT-HEVC/Build/linux/Release
9-
sudo cmake --install SVT-VP9/Build
10-
sudo cmake --build oneVPL/build --config Release --target install
11-
12-
sudo make install
13-
sudo ldconfig
3+
dir=$(dirname "$0")
4+
# shellcheck source=/dev/null
5+
. "$dir/common.sh" # for get_build_deps_excl
6+
7+
# build dir that will be restored from cache
8+
cache_dir=/var/tmp/ffmpeg
9+
10+
# install the deps - runs always (regardless the cache)
11+
deps() {
12+
ffmpeg_build_dep=$(get_build_deps_excl ffmpeg 'libsdl')
13+
# shellcheck disable=SC2086 # intentional
14+
sudo apt install $ffmpeg_build_dep libdav1d-dev libde265-dev \
15+
libopenh264-dev
16+
sudo apt-get -y remove 'libavcodec*' 'libavutil*' 'libswscale*' \
17+
libvpx-dev nginx
18+
}
19+
20+
install_aom() {(
21+
git clone --depth 1 https://aomedia.googlesource.com/aom
22+
mkdir -p aom/build
23+
cd aom/build
24+
cmake -DBUILD_SHARED_LIBS=1 ..
25+
cmake --build . --parallel "$(nproc)"
26+
sudo cmake --install .
27+
)}
28+
29+
install_libvpx() {(
30+
git clone --depth 1 https://github.com/webmproject/libvpx.git
31+
cd libvpx
32+
./configure --enable-pic --disable-examples --disable-install-bins \
33+
--disable-install-srcs --enable-vp9-highbitdepth
34+
make -j "$(nproc)"
35+
sudo make install
36+
)}
37+
38+
install_svt() {
39+
( git clone --depth 1 https://github.com/OpenVisualCloud/SVT-HEVC &&
40+
cd SVT-HEVC/Build/linux && ./build.sh release && cd Release &&
41+
sudo cmake --install . || exit 1 )
42+
( git clone --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git &&
43+
cd SVT-AV1 && cd Build &&
44+
cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release &&
45+
cmake --build . --parallel && sudo cmake --install . || exit 1 )
46+
( git clone --depth 1 https://github.com/OpenVisualCloud/SVT-VP9.git &&
47+
cd SVT-VP9/Build && cmake .. -DCMAKE_BUILD_TYPE=Release &&
48+
cmake --build . --parallel && sudo cmake --install . || exit 1 )
49+
# libsvtav1 in FFmpeg upstream, for SVT-HEVC now our custom patch in ffmpeg-patches
50+
# if patch apply fails, try increasing $FFMPEG_GIT_DEPTH
51+
git am -3 SVT-VP9/ffmpeg_plugin/master-*.patch
52+
# TOD TOREMOVE when not needed
53+
sed 's/\* avctx->ticks_per_frame//' libavcodec/libsvt_vp9.c >fix
54+
mv fix libavcodec/libsvt_vp9.c
55+
}
56+
57+
# The NV Video Codec SDK headers version 12.0 implies driver v520.56.06 in Linux
58+
install_nv_codec_headers() {
59+
git clone --depth 1 -b sdk/12.0 https://github.com/FFmpeg/nv-codec-headers
60+
( cd nv-codec-headers && make && sudo make install || exit 1 )
61+
}
62+
63+
install_onevpl() {(
64+
git clone --depth 1 https://github.com/oneapi-src/oneVPL
65+
mkdir oneVPL/build
66+
cd oneVPL/build
67+
cmake -DBUILD_TOOLS=OFF ..
68+
cmake --build . --config Release --parallel
69+
sudo cmake --build . --config Release --target install
70+
)}
71+
72+
# build FFmpeg deps + FFmpeg itself
73+
build_install() {
74+
rm -rf $cache_dir
75+
FFMPEG_GIT_DEPTH=5000 # greater depth is useful for 3-way merges
76+
git clone --depth $FFMPEG_GIT_DEPTH https://github.com/FFmpeg/FFmpeg.git \
77+
$cache_dir
78+
cd $cache_dir
79+
install_aom
80+
install_libvpx
81+
install_nv_codec_headers
82+
install_onevpl
83+
install_svt
84+
# apply patches
85+
find "$GITHUB_WORKSPACE/.github/scripts/Linux/ffmpeg-patches" \
86+
-name '*.patch' -print0 | sort -z | xargs -0 -n 1 git am -3
87+
./configure --disable-static --enable-shared --enable-gpl --enable-nonfree \
88+
--disable-sdl2 \
89+
--enable-libaom \
90+
--enable-libdav1d \
91+
--enable-libde265 \
92+
--enable-libmp3lame \
93+
--enable-libopenh264 \
94+
--enable-libopus \
95+
--enable-librav1e \
96+
--enable-libspeex \
97+
--enable-libsvtav1 \
98+
--enable-libsvthevc \
99+
--enable-libsvtvp9 \
100+
--enable-libvpl \
101+
--enable-libvpx \
102+
--enable-libx264 \
103+
--enable-libx265 \
104+
--enable-nvenc \
105+
--enable-vulkan \
106+
107+
make -j "$(nproc)"
108+
sudo make install
109+
sudo ldconfig
110+
}
111+
112+
# if cache is successfully restored, just install the builds
113+
install_cached() {
114+
cd $cache_dir
115+
( cd libvpx && sudo make install )
116+
( cd nv-codec-headers && sudo make install )
117+
( cd aom/build && sudo cmake --install . )
118+
sudo cmake --install SVT-AV1/Build
119+
sudo cmake --install SVT-HEVC/Build/linux/Release
120+
sudo cmake --install SVT-VP9/Build
121+
sudo cmake --build oneVPL/build --config Release --target install
122+
123+
sudo make install
124+
sudo ldconfig
125+
}
126+
127+
"${1?action required!}"

.github/scripts/Linux/prepare.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash -eux
22

33
dir=$(dirname "$0")
4-
# shellcheck source=/dev/null
5-
. "$dir/common.sh" # for get_build_deps_excl
64

75
export PKG_CONFIG_PATH=/usr/local/qt/lib/pkgconfig:/usr/local/lib/pkgconfig
86
export LIBRARY_PATH=/usr/local/lib:/usr/local/qt/lib
@@ -38,11 +36,7 @@ sudo apt install libcurl4-openssl-dev # for RTSP client (vidcap)
3836
sudo apt install i965-va-driver-shaders libva-dev # instead of i965-va-driver
3937

4038
"$dir/install_sdl.sh" deps
41-
42-
ffmpeg_build_dep=$(get_build_deps_excl ffmpeg 'libsdl')
43-
# shellcheck disable=SC2086 # intentional
44-
sudo apt install $ffmpeg_build_dep libdav1d-dev libde265-dev libopenh264-dev
45-
sudo apt-get -y remove 'libavcodec*' 'libavutil*' 'libswscale*' libvpx-dev nginx
39+
"$dir/install_ffmpeg.sh" deps
4640

4741
sudo apt install qt6-base-dev qt6-wayland
4842
. /etc/os-release # source ID and VERSION_ID

.github/workflows/ccpp.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ jobs:
8484
uses: actions/cache@main
8585
with:
8686
path: '/var/tmp/ffmpeg'
87-
key: cache-ffmpeg-${{ runner.os }}-${{ hashFiles( '.github/scripts/Linux/prepare.sh', '.github/scripts/Linux/download_build_ffmpeg.sh', '.github/scripts/Linux/ffmpeg-patches/*') }}
87+
key: cache-ffmpeg-${{ runner.os }}-${{ hashFiles( '.github/scripts/Linux/install_ffmpeg.sh', '.github/scripts/Linux/ffmpeg-patches/*') }}
8888
- name: Build FFmpeg
8989
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
90-
run: .github/scripts/Linux/download_build_ffmpeg.sh
90+
run: .github/scripts/Linux/install_ffmpeg.sh build_install
9191
- name: Install Cached FFmpeg
9292
if: steps.cache-ffmpeg.outputs.cache-hit == 'true'
93-
run: .github/scripts/Linux/install_ffmpeg.sh
93+
run: .github/scripts/Linux/install_ffmpeg.sh install_cached
9494
- name: Cache SDL
9595
id: cache-sdl
9696
uses: actions/cache@main

0 commit comments

Comments
 (0)