|
1 | 1 | #!/bin/bash -eux |
2 | 2 |
|
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!}" |
0 commit comments