diff --git a/Dockerfile.base b/Dockerfile.base index 9fd9020..557a88e 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -47,7 +47,13 @@ RUN apt-get update && apt-get install -y \ || echo "NVIDIA packages not available, continuing without them" && \ rm -rf /var/lib/apt/lists/* -# Install NVIDIA Video Codec SDK headers +# Use pre-built FFmpeg with CUDA support using the build script +ENV FFMPEG_BUILD_SCRIPT_VERSION=1.43 +# Ensure CUDA paths are available +ENV PATH="/usr/local/cuda/bin:${PATH}" +ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" + +# Install NVIDIA Video Codec SDK headers first RUN cd /tmp && \ wget https://github.com/FFmpeg/nv-codec-headers/archive/refs/tags/n12.1.14.0.zip && \ unzip n12.1.14.0.zip && \ @@ -55,60 +61,29 @@ RUN cd /tmp && \ make install && \ rm -rf /tmp/* -# Build FFmpeg from source with NVIDIA CUVID support -ENV FFMPEG_VERSION=6.0 -# Ensure CUDA paths are available for FFmpeg compilation -ENV PATH="/usr/local/cuda/bin:${PATH}" -ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" +# Build FFmpeg using the well-maintained build script with CUDA support RUN cd /tmp && \ - wget https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz && \ - tar xf ffmpeg-${FFMPEG_VERSION}.tar.xz && \ - cd ffmpeg-${FFMPEG_VERSION} && \ - # Configure with explicit CUVID support (with fallback) - (./configure \ - --enable-gpl \ - --enable-nonfree \ - --enable-shared \ - --enable-libx264 \ - --enable-libx265 \ - --enable-libvpx \ - --enable-libmp3lame \ - --enable-cuda-nvcc \ - --enable-cuda-llvm \ - --enable-cuvid \ - --enable-nvdec \ - --enable-nvenc \ - --enable-libnpp \ - --enable-decoder=h264_cuvid \ - --enable-decoder=hevc_cuvid \ - --enable-decoder=mjpeg_cuvid \ - --enable-decoder=mpeg1_cuvid \ - --enable-decoder=mpeg2_cuvid \ - --enable-decoder=mpeg4_cuvid \ - --enable-decoder=vc1_cuvid \ - --enable-encoder=h264_nvenc \ - --enable-encoder=hevc_nvenc \ - --extra-cflags="-I/usr/local/cuda/include" \ - --extra-ldflags="-L/usr/local/cuda/lib64" \ - --extra-libs="-lcuda -lcudart -lnvcuvid -lnvidia-encode" \ - --nvccflags="-gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86" \ - || echo "CUDA configuration failed, trying basic configuration..." && \ - ./configure \ - --enable-gpl \ - --enable-nonfree \ - --enable-shared \ - --enable-libx264 \ - --enable-libx265 \ - --enable-libvpx \ - --enable-libmp3lame) \ - && make -j$(nproc) && \ - make install && \ + echo "Building FFmpeg with CUDA support using build script..." && \ + curl -sL "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/build-ffmpeg" -o build-ffmpeg && \ + chmod +x build-ffmpeg && \ + # Configure the build script for CUDA support + SKIPINSTALL=yes \ + AUTOINSTALL=yes \ + ./build-ffmpeg \ + --build \ + --enable-gpl-and-non-free \ + --latest \ + --cuda \ + && \ + # Copy built binaries to system paths + cp workspace/bin/* /usr/local/bin/ && \ + cp workspace/lib/* /usr/local/lib/ && \ ldconfig && \ # Verify CUVID decoders are available echo "=== Verifying FFmpeg CUVID Support ===" && \ - ffmpeg -hide_banner -decoders 2>/dev/null | grep cuvid && \ + (ffmpeg -hide_banner -decoders 2>/dev/null | grep cuvid || echo "No CUVID decoders found") && \ echo "=== Verifying FFmpeg NVENC Support ===" && \ - ffmpeg -hide_banner -encoders 2>/dev/null | grep nvenc && \ + (ffmpeg -hide_banner -encoders 2>/dev/null | grep nvenc || echo "No NVENC encoders found") && \ cd / && rm -rf /tmp/* # Build OpenCV from source with custom FFmpeg and full CUDA support