# Cross-compilation image for x86_64 based on Debian 11 # Build on Debian 11 (GLIBC 2.31) for maximum runtime compatibility ARG DEBIAN_IMAGE=debian:11 FROM ${DEBIAN_IMAGE} ARG CHINAMIRRO=0 ARG GH_PROXY=https://gh-proxy.com/ ARG RUSTUP_DIST_SERVER_CN=https://rsproxy.cn ARG RUSTUP_UPDATE_ROOT_CN=https://rsproxy.cn/rustup ARG CARGO_INDEX_CN=https://rsproxy.cn/crates.io-index ARG CARGO_REGISTRY_CN=sparse+https://rsproxy.cn/index/ ARG LIBJPEG_TURBO_VERSION=3.1.4.1 ARG LIBYUV_REV=957f295ea946cbbd13fcfc46e7066f2efa801233 ARG LIBVPX_VERSION=1.16.0 ARG X265_VERSION=3.4 ARG OPUS_VERSION=1.5.2 ARG FFMPEG_ROCKCHIP_REV=40c412daccf08164493da0de990eb99a8948116b # Optionally use China mirrors for builds in China. RUN if [ "$CHINAMIRRO" = "1" ]; then \ sed -i -E \ -e 's|http://deb.debian.org/debian([[:space:]])|http://mirrors.tuna.tsinghua.edu.cn/debian\1|g' \ /etc/apt/sources.list; \ fi # Install Rust toolchain RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ ca-certificates \ && if [ "$CHINAMIRRO" = "1" ]; then \ export RUSTUP_DIST_SERVER=${RUSTUP_DIST_SERVER_CN}; \ export RUSTUP_UPDATE_ROOT=${RUSTUP_UPDATE_ROOT_CN}; \ fi \ && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable \ && if [ "$CHINAMIRRO" = "1" ]; then \ mkdir -p /root/.cargo; \ printf '%s\n' \ '[source.crates-io]' \ "replace-with = 'rsproxy-sparse'" \ '[source.rsproxy]' \ "registry = '${CARGO_INDEX_CN}'" \ '[source.rsproxy-sparse]' \ "registry = '${CARGO_REGISTRY_CN}'" \ '[registries.rsproxy]' \ "index = '${CARGO_INDEX_CN}'" \ '[net]' \ 'git-fetch-with-cli = true' \ > /root/.cargo/config.toml; \ fi \ && rm -rf /var/lib/apt/lists/* ENV PATH="/root/.cargo/bin:${PATH}" # Install build dependencies # Note: libyuv, libvpx, libx264, libx265, libopus are built from source below for static linking RUN apt-get update && apt-get install -y --no-install-recommends \ # Build tools build-essential \ pkg-config \ cmake \ nasm \ yasm \ git \ libclang-dev \ llvm \ wget \ xz-utils \ rsync \ # Autotools for libopus (requires autoreconf) autoconf \ automake \ libtool \ # Core system libraries libasound2-dev \ libv4l-dev \ libudev-dev \ linux-libc-dev \ zlib1g-dev \ # Note: libjpeg-turbo, libx264, libx265, libopus are built from source below for static linking libva-dev \ libdrm-dev \ libmfx-dev \ # X11 libraries (for VAAPI) libx11-dev \ libxcb1-dev \ libxau-dev \ libxdmcp-dev \ && rm -rf /var/lib/apt/lists/* # Build static libjpeg-turbo from source (needed by libyuv) RUN github_prefix="" \ && if [ "$CHINAMIRRO" = "1" ]; then github_prefix="${GH_PROXY%/}/"; fi \ && git init /tmp/libjpeg-turbo \ && cd /tmp/libjpeg-turbo \ && git remote add origin "${github_prefix}https://github.com/libjpeg-turbo/libjpeg-turbo.git" \ && git fetch --depth 1 origin "refs/tags/${LIBJPEG_TURBO_VERSION}" \ && git checkout --detach FETCH_HEAD \ && mkdir build && cd build \ && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_INSTALL_LIBDIR=lib \ -DENABLE_SHARED=OFF -DENABLE_STATIC=ON \ && make -j$(nproc) \ && make install \ && rm -rf /tmp/libjpeg-turbo # Build static libyuv from source (uses libjpeg-turbo headers) RUN git init /tmp/libyuv \ && cd /tmp/libyuv \ && github_prefix="" \ && if [ "$CHINAMIRRO" = "1" ]; then github_prefix="${GH_PROXY%/}/"; fi \ && git remote add origin "${github_prefix}https://github.com/lemenkov/libyuv" \ && git fetch --depth 1 origin ${LIBYUV_REV} \ && git checkout --detach FETCH_HEAD \ && mkdir build && cd build \ && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DJPEG_FOUND=TRUE \ -DJPEG_INCLUDE_DIR=/usr/local/include \ -DJPEG_LIBRARY=/usr/local/lib/libjpeg.a \ -DCMAKE_C_FLAGS="-DHAVE_JPEG -I/usr/local/include" \ -DCMAKE_CXX_FLAGS="-DHAVE_JPEG -I/usr/local/include" \ && make -j$(nproc) \ && make install \ && rm -rf /tmp/libyuv # Build static libvpx from source RUN github_prefix="" \ && if [ "$CHINAMIRRO" = "1" ]; then github_prefix="${GH_PROXY%/}/"; fi \ && git init /tmp/libvpx \ && cd /tmp/libvpx \ && git remote add origin "${github_prefix}https://github.com/webmproject/libvpx.git" \ && git fetch --depth 1 origin "refs/tags/v${LIBVPX_VERSION}" \ && git checkout --detach FETCH_HEAD \ && ./configure \ --enable-static --disable-shared --enable-pic \ --disable-examples --disable-tools --disable-docs \ --disable-unit-tests \ && make -j$(nproc) \ && make install \ && rm -rf /tmp/libvpx # Build static libx264 from source RUN github_prefix="" \ && if [ "$CHINAMIRRO" = "1" ]; then github_prefix="${GH_PROXY%/}/"; fi \ && git clone --depth 1 "${github_prefix}https://github.com/mirror/x264.git" /tmp/x264 \ && cd /tmp/x264 \ && ./configure --enable-static --disable-cli \ && make -j$(nproc) \ && make install \ && rm -rf /tmp/x264 # Build static libx265 from source RUN github_prefix="" \ && if [ "$CHINAMIRRO" = "1" ]; then github_prefix="${GH_PROXY%/}/"; fi \ && git init /tmp/x265 \ && cd /tmp/x265 \ && git remote add origin "${github_prefix}https://github.com/videolan/x265.git" \ && git fetch --depth 1 origin "refs/tags/${X265_VERSION}" \ && git checkout --detach FETCH_HEAD \ && cd source \ && mkdir -p build \ && cd build \ && cmake .. -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_ASM_NASM_FLAGS="-w-macro-params-legacy" \ -DENABLE_SHARED=OFF \ -DENABLE_CLI=OFF \ -DBUILD_SHARED_LIBS=OFF \ && make -j$(nproc) \ && make install \ && rm -rf /tmp/x265 # Create pkg-config file for x265 (required by FFmpeg) # Fix: Added -lstdc++ -lm -ldl -lpthread to Libs for static linking compatibility RUN mkdir -p /usr/local/lib/pkgconfig && \ cat > /usr/local/lib/pkgconfig/x265.pc <