diff --git a/Dockerfile.ffmpeg-static-alpine b/Dockerfile.ffmpeg-static-alpine new file mode 100644 index 00000000..4f790a3b --- /dev/null +++ b/Dockerfile.ffmpeg-static-alpine @@ -0,0 +1,127 @@ +# syntax=docker/dockerfile:1.3 + +# To build release: +# docker buildx build -f Dockerfile.ffmpeg-static-alpine -t ghcr.io/hybridgroup/ffmpeg:5.1.6-alpine --platform=linux/arm64,linux/amd64 --load . + +# Stage 1: Build OpenCV +FROM --platform=linux/amd64 alpine:3.20 AS builder-amd64 + +# Install dependencies +RUN apk update && apk add --no-cache \ + build-base \ + cmake \ + git \ + diffutils \ + perl \ + wget \ + unzip \ + pkgconfig \ + libjpeg-turbo-dev \ + libpng-dev \ + libwebp-dev \ + eigen-dev \ + nasm yasm \ + bzip2 xz zlib-dev x264-dev libvpx-dev \ + opus-dev dav1d-dev python3 + +ARG FFMPEG_VERSION=5.1.6 +ARG XZ_VERSION=5.6.3 + +# Build and install xz +RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \ + tar -xf xz-${XZ_VERSION}.tar.bz2 + +RUN cd xz-${XZ_VERSION} && \ + ./configure --disable-shared && \ + make && make install + +# Build and install bzip2 +RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \ + tar -xf bzip2-master.tar.bz2 + +RUN cd bzip2-master && \ + mkdir build && cd build && \ + cmake .. -DCMAKE_BUILD_TYPE="Release" -DENABLE_STATIC_LIB=ON -DENABLE_LIB_ONLY=ON && \ + cmake --build . --target install + +# Build and install ffmpeg + +RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \ + tar -xf ffmpeg-5.0.tar.bz2 + +# Build and install libvpx +RUN cd ffmpeg-${FFMPEG_VERSION} && \ + git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ + cd libvpx && \ + ./configure --enable-static --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm && \ + make -j $(nproc --all) && make install + +# Now finish building ffmpeg +RUN cd ffmpeg-${FFMPEG_VERSION} && \ + ./configure --pkg-config-flags="--static" \ + --enable-static --disable-shared --enable-gpl --enable-libx264 --enable-libvpx --enable-zlib \ + --disable-sdl2 --disable-vaapi --disable-vdpau --disable-v4l2-m2m --disable-doc && \ + make -j $(nproc --all) && make install + +FROM --platform=linux/arm64 alpine:3.20 AS builder-arm64 + +# Install dependencies +RUN apk update && apk add --no-cache \ + build-base \ + cmake \ + git \ + diffutils \ + perl \ + wget \ + unzip \ + pkgconfig \ + libjpeg-turbo-dev \ + libpng-dev \ + libwebp-dev \ + eigen-dev \ + nasm yasm \ + bzip2 xz zlib-dev x264-dev libvpx-dev \ + opus-dev dav1d-dev python3 + +ARG FFMPEG_VERSION=5.1.6 +ARG XZ_VERSION=5.6.3 + +# Build and install xz +RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \ + tar -xf xz-${XZ_VERSION}.tar.bz2 + +RUN cd xz-${XZ_VERSION} && \ + ./configure --disable-shared && \ + make && make install + +# Build and install bzip2 +RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \ + tar -xf bzip2-master.tar.bz2 + +RUN cd bzip2-master && \ + mkdir build && cd build && \ + cmake .. -DCMAKE_BUILD_TYPE="Release" -DENABLE_STATIC_LIB=ON -DENABLE_LIB_ONLY=ON && \ + cmake --build . --target install + +# Build and install ffmpeg +RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \ + tar -xf ffmpeg-5.0.tar.bz2 + +# Build and install libvpx +RUN cd ffmpeg-${FFMPEG_VERSION} && \ + git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ + cd libvpx && \ + ./configure --enable-static --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm && \ + make -j $(nproc --all) && make install + +# Now finish building ffmpeg +RUN cd ffmpeg-${FFMPEG_VERSION} && \ + ./configure --pkg-config-flags="--static" \ + --enable-static --disable-shared --enable-gpl --enable-libx264 --enable-libvpx --enable-zlib \ + --disable-sdl2 --disable-vaapi --disable-vdpau --disable-v4l2-m2m --disable-doc && \ + make -j $(nproc --all) && make install + +# Stage 2: Create final image +FROM builder-${TARGETARCH} AS final + +CMD ["ffmpeg"] diff --git a/Dockerfile.gstreamer-static-alpine b/Dockerfile.gstreamer-static-alpine new file mode 100644 index 00000000..61325595 --- /dev/null +++ b/Dockerfile.gstreamer-static-alpine @@ -0,0 +1,113 @@ +# To build release: +# docker buildx build -f Dockerfile.gstreamer-static-alpine -t ghcr.io/hybridgroup/gstreamer:1.24-alpine --platform=linux/arm64,linux/amd64 --load . + +FROM --platform=linux/amd64 alpine:3.20 AS builder-amd64 + +WORKDIR /gstreamer + +ARG GST_BUILD_VERSION=1.24 +RUN wget https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GST_BUILD_VERSION}/gstreamer-${GST_BUILD_VERSION}.tar.gz && \ + tar -xvzf gstreamer-${GST_BUILD_VERSION}.tar.gz + +WORKDIR /gstreamer/gstreamer-${GST_BUILD_VERSION} + +RUN apk update && apk add build-base \ + libxml2-dev \ + bison \ + flex \ + glib-dev \ + gobject-introspection-dev \ + libcap-dev \ + libcap-utils \ + meson \ + perl \ + wget \ + git \ + nasm + +RUN meson --default-library=static --prefix=/gstbin \ + -Dgst-full-target-type=static_library \ + -Dauto_features=disabled \ + -Dbase=enabled \ + -Dgood=enabled \ + -Dbad=enabled \ + -Dgst-plugins-base:typefind=enabled \ + -Dgst-plugins-base:playback=enabled \ + -Dgst-plugins-base:volume=enabled \ + -Dgst-plugins-base:audioconvert=enabled \ + -Dgst-plugins-base:app=enabled \ + -Dgst-plugins-good:isomp4=enabled \ + -Dgst-plugins-good:rtp=enabled \ + -Dgst-plugins-good:udp=enabled \ + -Dgst-plugins-good:rtsp=enabled \ + -Dgst-plugins-good:rtpmanager=enabled \ + -Dgst-plugins-good:audioparsers=enabled \ + -Dgst-plugins-bad:videoparsers=enabled \ + -Dgst-plugins-bad:codectimestamper=enabled \ + -Dgst-plugins-bad:openh264=enabled \ + -Dtools=disabled \ + build + +RUN meson compile -C build + +RUN meson install -C build + + +FROM --platform=linux/arm64 alpine:3.20 AS builder-arm64 + +WORKDIR /gstreamer + +ARG GST_BUILD_VERSION=1.24 +RUN wget https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GST_BUILD_VERSION}/gstreamer-${GST_BUILD_VERSION}.tar.gz && \ + tar -xvzf gstreamer-${GST_BUILD_VERSION}.tar.gz + +WORKDIR /gstreamer/gstreamer-${GST_BUILD_VERSION} + +RUN apk update && apk add build-base \ + libxml2-dev \ + bison \ + flex \ + glib-dev \ + gobject-introspection-dev \ + libcap-dev \ + libcap-utils \ + meson \ + perl \ + wget \ + git \ + nasm + +RUN meson --default-library=static --prefix=/gstbin \ + -Dgst-full-target-type=static_library \ + -Dauto_features=disabled \ + -Dbase=enabled \ + -Dgood=enabled \ + -Dbad=enabled \ + -Dgst-plugins-base:typefind=enabled \ + -Dgst-plugins-base:playback=enabled \ + -Dgst-plugins-base:volume=enabled \ + -Dgst-plugins-base:audioconvert=enabled \ + -Dgst-plugins-base:app=enabled \ + -Dgst-plugins-good:isomp4=enabled \ + -Dgst-plugins-good:rtp=enabled \ + -Dgst-plugins-good:udp=enabled \ + -Dgst-plugins-good:rtsp=enabled \ + -Dgst-plugins-good:rtpmanager=enabled \ + -Dgst-plugins-good:audioparsers=enabled \ + -Dgst-plugins-bad:videoparsers=enabled \ + -Dgst-plugins-bad:codectimestamper=enabled \ + -Dgst-plugins-bad:openh264=enabled \ + -Dtools=disabled \ + build + +RUN meson compile -C build + +RUN meson install -C build + +ARG TARGETARCH + +FROM builder-${TARGETARCH} AS final + +ENV PATH=/gstbin/bin:${PATH} +ENV LD_LIBRARY_PATH=/usr/lib:/gstbin/lib:/usr/local/lib:${LD_LIBRARY_PATH} +ENV PKG_CONFIG_PATH=/gstbin/lib/pkgconfig diff --git a/Dockerfile.opencv-static-alpine b/Dockerfile.opencv-static-alpine index d5dd3a2e..8041fe51 100644 --- a/Dockerfile.opencv-static-alpine +++ b/Dockerfile.opencv-static-alpine @@ -3,8 +3,12 @@ # To build release: # docker buildx build -f Dockerfile.opencv-static-alpine -t ghcr.io/hybridgroup/opencv:4.10-alpine --platform=linux/arm64,linux/amd64 --load . +FROM --platform=linux/amd64 ghcr.io/hybridgroup/gstreamer:1.24-alpine AS gstreamer-amd64 + +FROM --platform=linux/arm64 ghcr.io/hybridgroup/gstreamer:1.24-alpine AS gstreamer-arm64 + # Stage 1: Build OpenCV -FROM --platform=linux/amd64 alpine:3.20 AS builder-amd64 +FROM --platform=linux/amd64 ghcr.io/hybridgroup/ffmpeg:5.1.6-alpine AS builder-amd64 # Install dependencies RUN apk update && apk add --no-cache \ @@ -22,48 +26,12 @@ RUN apk update && apk add --no-cache \ eigen-dev \ nasm yasm \ bzip2 xz zlib-dev x264-dev libvpx-dev \ - opus-dev dav1d-dev \ - gstreamer-dev gst-plugins-base-dev gstreamer gst-plugins-bad gst-plugins-good gst-plugins-base gst-plugins-ugly openssl gst-libav - -# Build and install xz -ARG XZ_VERSION=5.6.3 - -RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \ - tar -xf xz-${XZ_VERSION}.tar.bz2 - -RUN cd xz-${XZ_VERSION} && \ - ./configure --disable-shared && \ - make && make install - -# Build and install bzip2 -RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \ - tar -xf bzip2-master.tar.bz2 - -RUN cd bzip2-master && \ - mkdir build && cd build && \ - cmake .. -DCMAKE_BUILD_TYPE="Release" -DENABLE_STATIC_LIB=ON -DENABLE_LIB_ONLY=ON && \ - cmake --build . --target install - -# Build and install ffmpeg -ARG FFMPEG_VERSION=5.1.6 - -RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \ - tar -xf ffmpeg-5.0.tar.bz2 - -# Build and install libvpx -RUN cd ffmpeg-${FFMPEG_VERSION} && \ - git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ - cd libvpx && \ - ./configure --enable-static --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm && \ - make -j $(nproc --all) && make install - -# Now finish building ffmpeg -RUN cd ffmpeg-${FFMPEG_VERSION} && \ - ./configure --pkg-config-flags="--static" \ - --enable-static --disable-shared --enable-gpl --enable-libx264 --enable-libvpx --enable-zlib \ - --disable-sdl2 --disable-vaapi --disable-vdpau --disable-v4l2-m2m --disable-doc && \ - make -j $(nproc --all) && make install - + opus-dev dav1d-dev openssl + +# copy gstreamer +COPY --from=gstreamer-amd64 /gstbin/lib /usr/local/lib +COPY --from=gstreamer-amd64 /gstbin/include /usr/local/include + # Set OpenCV version ARG OPENCV_VERSION=4.10.0 @@ -93,7 +61,7 @@ RUN cmake -D CMAKE_BUILD_TYPE=Release \ -D OPENCV_ENABLE_NONFREE=ON \ -D BUILD_SHARED_LIBS=OFF \ -D WITH_FFMPEG=ON \ - -D WITH_GSTREAMER=OFF \ + -D WITH_GSTREAMER=ON \ -D WITH_TBB=ON \ -D WITH_SIMD=ON \ -D BUILD_EXAMPLES=OFF \ @@ -118,7 +86,7 @@ RUN cmake -D CMAKE_BUILD_TYPE=Release \ make -j$(nproc) && \ make install -FROM --platform=linux/arm64 alpine:3.20 AS builder-arm64 +FROM --platform=linux/arm64 ghcr.io/hybridgroup/ffmpeg:5.1.6-alpine AS builder-arm64 # Install dependencies RUN apk update && apk add --no-cache \ @@ -136,48 +104,12 @@ RUN apk update && apk add --no-cache \ eigen-dev \ nasm yasm \ bzip2 xz zlib-dev x264-dev libvpx-dev \ - opus-dev dav1d-dev \ - gstreamer-dev gst-plugins-base-dev gstreamer gst-plugins-bad gst-plugins-good gst-plugins-base gst-plugins-ugly openssl gst-libav - -# Build and install xz -ARG XZ_VERSION=5.6.3 - -RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \ - tar -xf xz-${XZ_VERSION}.tar.bz2 - -RUN cd xz-${XZ_VERSION} && \ - ./configure --disable-shared && \ - make && make install - -# Build and install bzip2 -RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \ - tar -xf bzip2-master.tar.bz2 - -RUN cd bzip2-master && \ - mkdir build && cd build && \ - cmake .. -DCMAKE_BUILD_TYPE="Release" -DENABLE_STATIC_LIB=ON -DENABLE_LIB_ONLY=ON && \ - cmake --build . --target install - -# Build and install ffmpeg -ARG FFMPEG_VERSION=5.1.6 - -RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \ - tar -xf ffmpeg-5.0.tar.bz2 - -# Build and install libvpx -RUN cd ffmpeg-${FFMPEG_VERSION} && \ - git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \ - cd libvpx && \ - ./configure --enable-static --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm && \ - make -j $(nproc --all) && make install - -# Now finish building ffmpeg -RUN cd ffmpeg-${FFMPEG_VERSION} && \ - ./configure --pkg-config-flags="--static" \ - --enable-static --disable-shared --enable-gpl --enable-libx264 --enable-libvpx --enable-zlib \ - --disable-sdl2 --disable-vaapi --disable-vdpau --disable-v4l2-m2m --disable-doc && \ - make -j $(nproc --all) && make install - + opus-dev dav1d-dev openssl + +# copy gstreamer +COPY --from=gstreamer-arm64 /gstbin/lib /usr/local/lib +COPY --from=gstreamer-arm64 /gstbin/include /usr/local/include + # Set OpenCV version ARG OPENCV_VERSION=4.10.0 @@ -206,7 +138,7 @@ RUN cmake -D CMAKE_BUILD_TYPE=Release \ -D OPENCV_ENABLE_NONFREE=ON \ -D BUILD_SHARED_LIBS=OFF \ -D WITH_FFMPEG=ON \ - -D WITH_GSTREAMER=OFF \ + -D WITH_GSTREAMER=ON \ -D WITH_TBB=ON \ -D WITH_SIMD=ON \ -D ENABLE_LIBJPEG_TURBO_SIMD=OFF \