FROM nextream/ffmpeg-ndi:v5.1 USER root RUN apt-get update \ && apt-get install -y --no-install-recommends \ libxcb1 libxcb-shm0 libxcb-shape0 libxcb-xfixes0 \ libasound2 libsdl2-2.0-0 libsndio7.0 libxv1 libx11-6 libxext6 \ libva2 libva-drm2 libva-x11-2 libvdpau1 libavahi-common3 libavahi-client3 libpulse0 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # add compatibility symlink for libvpx if ffmpeg expects a newer SONAME RUN set -eux; \ if [ -f /usr/lib/x86_64-linux-gnu/libvpx.so.7 ] && [ ! -f /usr/lib/x86_64-linux-gnu/libvpx.so.9 ]; then \ ln -s /usr/lib/x86_64-linux-gnu/libvpx.so.7 /usr/lib/x86_64-linux-gnu/libvpx.so.9 || true; \ fi RUN set -eux; \ if apt-get update >/dev/null 2>&1; then \ apt-get install -y --no-install-recommends libx264-163 build-essential gcc pkg-config git yasm nasm || true; \ ldconfig || true; \ fi ## Remove any distro-provided libx264 so our built x264 is the only one present. RUN set -eux; \ rm -f /usr/lib/x86_64-linux-gnu/libx264.so* /usr/local/lib/libx264.so || true; \ ldconfig || true RUN set -eux; \ # Build x264 from source and install shared libs to satisfy ffmpeg cd /tmp; \ git clone --depth 1 https://code.videolan.org/videolan/x264.git x264-src || true; \ cd x264-src || true; \ ./configure --enable-shared --enable-pic --disable-cli || true; \ make -j$(nproc) || true; \ make install || true; \ ldconfig || true; \ rm -rf /tmp/x264-src || true RUN set -eux; \ # Build a small compatibility shim that provides x264_encoder_open_164 by # forwarding to the real symbol in the installed x264 (usually x264_encoder_open_165). # Use a tiny alias shim so the exact symbol x264_encoder_open_164 is available printf '%s\n' 'extern void *x264_encoder_open_165(void *);' 'void *x264_encoder_open_164(void *p) __attribute__((alias("x264_encoder_open_165")));' > /tmp/x264_alias.c; \ gcc -shared -fPIC -o /usr/lib/x86_64-linux-gnu/libx264.so.164 /tmp/x264_alias.c || true; \ rm -f /tmp/x264_compat.c || true; \ ldconfig || true RUN set -eux; \ # Create compatibility symlinks so binaries looking for libx264.so.164 find our build if [ -f /usr/local/lib/libx264.so.165 ]; then \ ln -sf /usr/local/lib/libx264.so.165 /usr/lib/x86_64-linux-gnu/libx264.so.165 || true; \ ln -sf /usr/local/lib/libx264.so.165 /usr/lib/x86_64-linux-gnu/libx264.so.164 || true; \ ln -sf /usr/local/lib/libx264.so.165 /usr/lib/x86_64-linux-gnu/libx264.so.163 || true; \ ldconfig || true; \ fi RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends autoconf automake libtool pkg-config texinfo zlib1g-dev libx264-dev libvpx-dev libfdk-aac-dev libmp3lame-dev libopus-dev libx265-dev libnuma-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb-shape0-dev libasound2-dev libpulse-dev libavahi-client-dev libva-dev libvdpau-dev libx11-dev libxext-dev yasm nasm git build-essential ca-certificates && \ cd /tmp && git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg-src || true && \ # Ensure we use the x264 we installed into /usr/local export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig; \ cd ffmpeg-src && \ ./configure --prefix=/usr/local --pkg-config-flags="--static" --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --extra-libs="-lpthread -lm" --enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libfdk-aac --enable-nonfree --enable-libndi_newtek || true && \ make -j$(nproc) || true && make install || true && ldconfig || true && rm -rf /tmp/ffmpeg-src; \ apt-get remove -y --purge autoconf automake libtool pkg-config build-essential texinfo ca-certificates git || true; apt-get autoremove -y --purge; rm -rf /var/lib/apt/lists/* CMD ["/usr/local/bin/ffmpeg","-hide_banner","-version"]