Files
spacedrive/.github/scripts/ffmpeg-windows/Dockerfile
Vítor Vasconcellos 1c7855ded6 [ENG-630] Windows ffmpeg + libheif custom build (#871)
* Initial Windows ffmpeg + libheif custom build

* Add build steps for most of ffmpeg deps

* FFmpeg deps and libheif

* Fix libheif build

* Fix libvpx and dlfcn + attempt to fix rav1e

* Rework the whole ffmpeg-windows build system
 - New system based on https://github.com/BtbN/FFmpeg-Builds
 - Add new ffmpeg-windows workflow
 - Rename macos ffmpeg workflow
 - Adapt macos setupt script due to above name change

* Forgot to update update the workflow name

* Strip all libs from debug symbols

* Add docs

* Add libde265 deps, required by libheif
 - Make x265, svtav1 and dav1d as shared deps (used by both ffmpeg and libheif)

* Add missing libheif to Linux setup script

* Fix libx265 build script

* Forgot to point x265 ninja install to the correct directory

* Remove libaom and libsvt-av1
 - dav1d and rav1d are our default AV1 decoders/encoders
 - Quote subshell executions
 - Make libweb shared

* Forgot to remove libaom and libsvt-av1 build steps

* Fix typo

* Try force webp to link against static libs

* Revert libwebp to a static build

* Dumb typo

* Modify windows script to download our ffmpeg build (WIP)

* Fix dlls output folder structure

* Fix dumb mistake

* Remove unused ffbuild_enabled

* Enable core's heif feature on Windows
 - Fix windows ffmpeg build not including the headers
 - Fix windows setupt script incorrect download loagic
 - Implement build_arg to pass which repo ref to use when cloning

* Fix windows setup script

* Fix workflow artifact path
 - Make ffmpeg-windows dockerfile respect the FFMPEG_VERSION env

* Fix Windows setup script incorrect logic for downloading ffmpeg builds

* Error out when workflow_runs is empty

* Fix dumb mistake

* Manually define ffmpeg version for windows script

* Fix ffmpeg windows build extract logic

* Fix prop access in windows setup script

* Revert back to a web request because nightly.link does a redirect before serving the artifact content

* Fix windows setup script

* Do not use nightly.link in Github CI

* Fix windows setup script

* Should finally fix window setup script
 - Update ffmpeg-windows deps
 - Should fix ffmpeg-windows failing to build due to mingw changes in new base image

* Fix libxz failing to build due to doxygen

* Fix windows setup-script not executing till the end

* Fix LASTEXITCODE not defined

* Remove libjxl, deps are not being compiled

* Fix dll and lib copy logic

* Move final copy dll logic to external script

* Use main for libjxl

* Change brotli from stable to main
 - Attempt to fix libjxl

* Attempt fix lib copy again

* Split copy_dll logic to avoid cache burst in docker

* Missing file

* Change how to export build files from shared deps

* Replace rsync with cp

* Fix copy

* Fix dir not existing

* Fix pkgconfig

* Remove superflous files from exported ffmpeg for windows
 - Adjust dav1d to not build tools and examples
 - Adjust windows setup-script to point linker to the libs directory

* Fix dav1d meson config args

* Fix dumb mistake

* WORK PLZ

* Fix .lib file location
 - Strip all dlls

* Formatter
2023-06-10 15:23:37 +00:00

243 lines
6.7 KiB
Docker

ARG FFMPEG_VERSION=6.0
FROM ghcr.io/btbn/ffmpeg-builds/base-win64:latest@sha256:69e7ee385c41ae4580161fbd1cf14e1d199a81c39e398e8421225d86d8f2d3f3 AS base
ENV TARGET=win64
FROM base AS layer-10-mingw
RUN --mount=src=scripts.d/10-mingw.sh,dst=/stage.sh run_stage /stage.sh
FROM base AS layer-10-mingw-std-threads
RUN --mount=src=scripts.d/10-mingw-std-threads.sh,dst=/stage.sh run_stage /stage.sh
FROM base AS layer-10
COPY --from=layer-10-mingw /opt/mingw/. /
COPY --from=layer-10-mingw /opt/mingw/. /opt/mingw
COPY --from=layer-10-mingw-std-threads $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-10 AS layer-20-zlib
RUN --mount=src=scripts.d/20-zlib.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-10 AS layer-20-bzip2
RUN --mount=src=scripts.d/20-bzip2.sh,dst=/stage.sh --mount=src=patches/bzip2,dst=/patches run_stage /stage.sh
FROM layer-10 AS layer-20
COPY --from=layer-20-zlib $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-20-bzip2 $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-20 AS layer-25-libogg
RUN --mount=src=scripts.d/25-libogg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-20 AS layer-25-xz
RUN --mount=src=scripts.d/25-xz.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-20 AS layer-25
COPY --from=layer-25-libogg $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-25-xz $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-25 AS layer-45-brotli
RUN --mount=src=scripts.d/45-brotli.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45-libvorbis
RUN --mount=src=scripts.d/45-libvorbis.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45-opencl
RUN --mount=src=scripts.d/45-opencl.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45-vmaf
RUN --mount=src=scripts.d/45-vmaf.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45
COPY --from=layer-45-brotli $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-45-libvorbis $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-45-opencl $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-45-vmaf $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-45 AS layer-50-amf
RUN --mount=src=scripts.d/50-amf.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-dav1d
RUN --mount=src=scripts.d/50-dav1d.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-ffnvcodec
RUN --mount=src=scripts.d/50-ffnvcodec.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-kvazaar
RUN --mount=src=scripts.d/50-kvazaar.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libjxl
RUN --mount=src=scripts.d/50-libjxl.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libmp3lame
RUN --mount=src=scripts.d/50-libmp3lame.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libopus
RUN --mount=src=scripts.d/50-libopus.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libtheora
RUN --mount=src=scripts.d/50-libtheora.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libvpx
RUN --mount=src=scripts.d/50-libvpx.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libwebp
RUN --mount=src=scripts.d/50-libwebp.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-onevpl
RUN --mount=src=scripts.d/50-onevpl.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-openal
RUN --mount=src=scripts.d/50-openal.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-openjpeg
RUN --mount=src=scripts.d/50-openjpeg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-rav1e
RUN --mount=src=scripts.d/50-rav1e.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-soxr
RUN --mount=src=scripts.d/50-soxr.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-twolame
RUN --mount=src=scripts.d/50-twolame.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-vulkan
RUN --mount=src=scripts.d/50-vulkan/45-vulkan.sh,dst=/stage.sh run_stage /stage.sh
RUN --mount=src=scripts.d/50-vulkan/50-shaderc.sh,dst=/stage.sh run_stage /stage.sh
RUN --mount=src=scripts.d/50-vulkan/55-spirv-cross.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-x264
RUN --mount=src=scripts.d/50-x264.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-x265
RUN --mount=src=scripts.d/50-x265.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-xvid
RUN --mount=src=scripts.d/50-xvid.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-zimg
RUN --mount=src=scripts.d/50-zimg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50
COPY --from=layer-50-amf $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-dav1d $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-dav1d /opt/dlls /opt/dlls
COPY --from=layer-50-ffnvcodec $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-kvazaar $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libjxl $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libmp3lame $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libopus $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libtheora $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libvpx $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libwebp $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-onevpl $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-openal $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-openjpeg $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-rav1e $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-rav1e /opt/dlls /opt/dlls
COPY --from=layer-50-soxr $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-twolame $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-vulkan $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-x264 $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-x265 $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-x265 /opt/dlls /opt/dlls
COPY --from=layer-50-xvid $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-zimg $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-50 AS layer-99-libheif
RUN --mount=src=scripts.d/99-libheif.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-50 AS layer-99-ffmpeg
ARG FFMPEG_VERSION
ENV FFMPEG_VERSION="$FFMPEG_VERSION"
RUN --mount=src=scripts.d/99-ffmpeg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-50 AS layer-99
COPY --from=layer-50 /opt/dlls /opt/dlls
COPY --from=layer-99-libheif /opt/dlls /opt/dlls
COPY --from=layer-99-ffmpeg /opt/dlls /opt/dlls
RUN rm -rf /opt/dlls/share /opt/dlls/lib/pkgconfig /opt/dlls/lib/cmake
RUN cd /opt/dlls/bin \
&& find . -name '*.lib' -exec install -Dt ../lib/ -m a-rwx,u+rw,g+r,o+r {} + \
&& find . -name '*.lib' -delete \
&& find . -name '*.dll' -exec x86_64-w64-mingw32-strip -s {} \;
RUN find /opt/dlls -type d -delete || true
FROM scratch
COPY --from=layer-99 /opt/dlls /dlls