diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..c0ae7cd --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,125 @@ +name: build + +on: + push: + branches: [main] + paths-ignore: + - '**.md' + - 'docs/**' + - 'BENCHMARKS.md' + - 'ROADMAP.md' + - 'CHANGELOG.md' + - 'LICENSE' + - '.gitea/ISSUE_TEMPLATE/**' + pull_request: + branches: [main] + +jobs: + cmake-build: + name: cmake build (CUDA 12.4, Ubuntu 22.04) + runs-on: ubuntu-22.04 + container: + image: nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 + steps: + - name: Install build deps + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends \ + build-essential cmake ninja-build pkg-config git \ + libavformat-dev libavcodec-dev libavutil-dev libswscale-dev \ + ca-certificates + + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure (full — libcuframes + examples + tools) + run: | + cmake -B build -S . -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_TESTING=OFF \ + -DBUILD_EXAMPLES=ON \ + -DBUILD_TOOLS=ON \ + -DBUILD_FFMPEG_FILTER=OFF \ + -DBUILD_PYTHON_BINDINGS=OFF + + - name: Build + run: cmake --build build --parallel + + - name: Verify produced binaries + library + run: | + ls -la build/libcuframes/libcuframes.so* + ls -la build/libcuframes/libcuframes_static.a + ls -la build/tools/cuframes-rtsp-source/cuframes-rtsp-source + ls -la build/examples/sub_count/sub_count + ./build/tools/cuframes-rtsp-source/cuframes-rtsp-source --help | head -5 + + - name: Install + verify install layout + run: | + cmake --install build --prefix /tmp/cuframes-install + test -f /tmp/cuframes-install/include/cuframes/cuframes.h + test -f /tmp/cuframes-install/include/cuframes/cuframes.hpp + test -f /tmp/cuframes-install/lib/libcuframes.so + test -f /tmp/cuframes-install/lib/libcuframes_static.a + + filter-build: + name: ffmpeg filter patch (out-of-tree) + runs-on: ubuntu-22.04 + container: + image: nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 + needs: cmake-build + steps: + - name: Install build deps + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends \ + build-essential cmake ninja-build pkg-config git nasm \ + libssl-dev libx264-dev libx265-dev libnuma-dev zlib1g-dev \ + ca-certificates wget patch + + - name: Checkout + uses: actions/checkout@v4 + + - name: Build libcuframes (для linking в patched ffmpeg) + run: | + cmake -B build -S . -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TOOLS=OFF + cmake --build build --parallel + cmake --install build --prefix /opt/cuframes + + - name: Clone FFmpeg n7.1 + apply patch + run: | + git clone --depth 1 --branch n7.1 https://github.com/FFmpeg/FFmpeg.git /src/ffmpeg + cd /src/ffmpeg + patch -p1 < $GITHUB_WORKSPACE/filter/ffmpeg-7.1-cuframes-demuxer.patch + ls libavformat/cuframesdec.c + + - name: Configure FFmpeg (minimal + libcuframes) + run: | + cd /src/ffmpeg + ./configure \ + --prefix=/opt/ffmpeg \ + --enable-libcuframes \ + --extra-cflags="-I/opt/cuframes/include -I/usr/local/cuda/include" \ + --extra-ldflags="-L/opt/cuframes/lib -L/usr/local/cuda/lib64" \ + --extra-libs="-lcudart -lpthread -lrt -lm" \ + --disable-x86asm --disable-everything \ + --enable-demuxer=cuframes,rawvideo \ + --enable-decoder=rawvideo \ + --enable-muxer=null,rawvideo \ + --enable-protocol=file --enable-ffmpeg \ + --disable-doc --disable-htmlpages --disable-manpages \ + --disable-podpages --disable-txtpages + + - name: Build FFmpeg + run: | + cd /src/ffmpeg + make -j$(nproc) ffmpeg + + - name: Verify cuframes demuxer registered + run: | + export LD_LIBRARY_PATH=/opt/cuframes/lib + /src/ffmpeg/ffmpeg -hide_banner -formats | grep cuframes + /src/ffmpeg/ffmpeg -hide_banner -h demuxer=cuframes | head -10 diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..e1f7412 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,78 @@ +name: release + +# Триггер: push tag v* (e.g. v0.1.0, v0.2.0). +# Сборка: runtime Docker image + source tarball, прикладываем к gitea release. + +on: + push: + tags: + - 'v*' + +jobs: + docker-runtime: + name: build runtime Docker image + runs-on: ubuntu-22.04 + container: + image: docker.gitea.com/runner-images:ubuntu-22.04 + # docker socket нужен — gitea runner монтирует /var/run/docker.sock + volumes: + - /var/run/docker.sock:/var/run/docker.sock + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Tag from ref + id: tag + run: | + TAG="${GITHUB_REF#refs/tags/v}" + echo "version=$TAG" >> $GITHUB_OUTPUT + + - name: Login to gitea registry + run: | + echo "${{ secrets.GITEA_TOKEN }}" | docker login git.goldix.org \ + -u "${{ github.actor }}" --password-stdin + + - name: Build runtime image + run: | + docker build -f docker/Dockerfile.runtime \ + -t git.goldix.org/gx/cuframes:${{ steps.tag.outputs.version }} \ + -t git.goldix.org/gx/cuframes:latest \ + . + + - name: Push + run: | + docker push git.goldix.org/gx/cuframes:${{ steps.tag.outputs.version }} + docker push git.goldix.org/gx/cuframes:latest + + source-tarball: + name: build source tarball + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Tag from ref + id: tag + run: | + TAG="${GITHUB_REF#refs/tags/v}" + echo "version=$TAG" >> $GITHUB_OUTPUT + + - name: Create tarball + run: | + VERSION="${{ steps.tag.outputs.version }}" + mkdir -p /tmp/release + git archive --format=tar.gz --prefix="cuframes-$VERSION/" \ + -o "/tmp/release/cuframes-$VERSION.tar.gz" HEAD + ls -la /tmp/release/ + + # Готовый artifact — пользователь скачает с release page либо attached к release. + # Gitea release upload через API делается отдельным шагом (см. gitea/release-action + # либо curl); тут оставляем артефакт как build output для последующего ручного + # attach. Для полной автоматизации — добавить шаг upload через curl + GITEA_TOKEN. + - name: Upload tarball as artifact + uses: actions/upload-artifact@v3 + with: + name: cuframes-${{ steps.tag.outputs.version }}-source + path: /tmp/release/cuframes-*.tar.gz diff --git a/README.md b/README.md index 56d8a4e..ea1b961 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,15 @@ # cuframes +[![build](https://git.goldix.org/gx/cuframes/actions/workflows/build.yml/badge.svg?branch=main)](https://git.goldix.org/gx/cuframes/actions?workflow=build.yml) +[![release](https://img.shields.io/badge/release-v0.1.0-blue)](https://git.goldix.org/gx/cuframes/releases/tag/v0.1.0) +[![license](https://img.shields.io/badge/license-LGPL--2.1+-green)](LICENSE) + Zero-copy sharing декодированных видеокадров между процессами через CUDA IPC. -**Статус:** v0.1 — libcuframes готов, cuframes-rtsp-source готов, e2e-pipeline -протестирован (4×subscriber × 2000 frames, 0 torn). FFmpeg filter — v0.2. -**Лицензия:** LGPL-2.1+ +**Статус:** v0.1.0 released — production-deployed на multi-camera CCTV-стeке +(Frigate + custom C++ processor, оба используют один publisher на одном NVDEC). +См. [BENCHMARKS.md](BENCHMARKS.md) для measurements, [ROADMAP.md](ROADMAP.md) +для v0.2 plans. ## Минимальные требования