From 0182cd0306f22b28dac5bc99e802924c72a1a864 Mon Sep 17 00:00:00 2001 From: Maxim Raznatovski Date: Fri, 31 Oct 2025 11:14:23 +0100 Subject: [PATCH] Use system version of FFmpeg for Resonate (#2577) --- .github/workflows/release.yml | 4 ++-- Dockerfile | 12 ++++++++++++ Dockerfile.base | 9 +++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84507c79..1899c2c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,8 +34,8 @@ on: env: PYTHON_VERSION: "3.12" BASE_IMAGE_VERSION_STABLE: "1.3.1" - BASE_IMAGE_VERSION_BETA: "1.4.4" - BASE_IMAGE_VERSION_NIGHTLY: "1.4.4" + BASE_IMAGE_VERSION_BETA: "1.4.5" + BASE_IMAGE_VERSION_NIGHTLY: "1.4.5" jobs: preflight-checks: diff --git a/Dockerfile b/Dockerfile index a52dd3ed..d5a007c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,13 @@ COPY requirements_all.txt . # ensure UV is installed COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +# Install build tools for PyAV compilation (for aioresonate) +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + g++ \ + python3-dev \ + && rm -rf /var/lib/apt/lists/* + # create venv which will be copied to the final image ENV VIRTUAL_ENV=/app/venv RUN uv venv $VIRTUAL_ENV @@ -21,6 +28,11 @@ RUN uv venv $VIRTUAL_ENV RUN uv pip install \ -r requirements_all.txt +# Reinstall PyAV from source to use system FFmpeg instead of bundled FFmpeg +# Use the version already resolved by requirements_all.txt to ensure compatibility +RUN uv pip install --no-binary av --force-reinstall --no-deps \ + "av==$($VIRTUAL_ENV/bin/python -c 'import importlib.metadata; print(importlib.metadata.version("av"))')" + # Install Music Assistant from prebuilt wheel ARG MASS_VERSION RUN uv pip install \ diff --git a/Dockerfile.base b/Dockerfile.base index 93456516..ead2079e 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -155,6 +155,8 @@ RUN set -x \ libflac12 \ libavahi-client3 \ libavahi-common3 \ + # pkg-config needed for PyAV (for aioresonate) to find system FFmpeg + pkg-config \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -179,6 +181,13 @@ COPY --from=ffmpeg-builder /usr/local/lib/libav*.so* /usr/local/lib/ COPY --from=ffmpeg-builder /usr/local/lib/libsw*.so* /usr/local/lib/ COPY --from=ffmpeg-builder /usr/local/lib/libpostproc.so* /usr/local/lib/ +# Copy FFmpeg headers and pkg-config files needed for PyAV compilation (adds around 2 MB) +COPY --from=ffmpeg-builder /usr/local/include/ /usr/local/include/ +COPY --from=ffmpeg-builder /usr/local/lib/pkgconfig/ /usr/local/lib/pkgconfig/ + +# Set PKG_CONFIG_PATH so pkg-config can find FFmpeg +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig + # Update shared library cache and verify FFmpeg RUN ldconfig && ffmpeg -version && ffprobe -version -- 2.34.1