Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ jobs:
- os: ubuntu-latest
CC: gcc
CXX: g++
CUDA: "true"
- os: ubuntu-latest
CC: gcc
CXX: g++
CUDA: "false"
- os: macos-latest
CC: clang
CXX: clang++
CUDA: "false"
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
CUDA: ${{ matrix.CUDA }}
steps:
- name: Setup python
uses: actions/setup-python@v5
Expand All @@ -37,16 +44,33 @@ jobs:
run: |
sudo apt-get update
sudo -E apt-get -yq install ninja-build gcc nasm
- name: Setup CUDA
if: matrix.CUDA == 'true'
uses: Jimver/cuda-toolkit@v0.2.24
id: cuda-toolkit
- name: Install nv-codec-headers
if: matrix.CUDA == 'true'
run: |
git clone -q --branch master --depth=1 "https://github.com/FFmpeg/nv-codec-headers" nv-codec-headers
cd nv-codec-headers
make && make install
- name: Install dependencies (mac)
if: matrix.os == 'macos-latest'
run: |
brew install -q ninja nasm
- uses: actions/checkout@v4
- name: Build vmaf
run: |
meson setup libvmaf libvmaf/build --buildtype release
meson setup libvmaf libvmaf/build --buildtype release -Denable_cuda=$CUDA
sudo ninja -vC libvmaf/build install
- name: Prepare FFmpeg CUDA
if: matrix.CUDA == 'true'
run: |
git clone -q --branch master --depth=1 "https://github.com/FFmpeg/FFmpeg" ffmpeg
cd ffmpeg
./configure --enable-version3 --enable-ffnvcodec --enable-libvmaf --disable-indevs --cc="$CC" --cxx="$CXX" || { less ffbuild/config.log; exit 1; }
- name: Prepare FFmpeg
if: matrix.CUDA == 'false'
run: |
git clone -q --branch master --depth=1 "https://github.com/FFmpeg/FFmpeg" ffmpeg
cd ffmpeg
Expand Down
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:22.04
ARG NV_CODEC_TAG="876af32a202d0de83bd1d36fe74ee0f7fcf86b0d"

# get and install building tools
RUN apt-get update && \
Expand All @@ -10,16 +11,24 @@ RUN apt-get update && \
python3 \
python3-pip \
python3-venv \
xxd
xxd \
clang \
wget \
unzip \
nvidia-cuda-dev \
nvidia-cuda-toolkit

# retrieve source code
COPY . /vmaf

# setup environment
ENV PATH=/vmaf:/vmaf/libvmaf/build/tools:$PATH

RUN wget https://github.com/FFmpeg/nv-codec-headers/archive/${NV_CODEC_TAG}.zip && unzip ${NV_CODEC_TAG}.zip && cd nv-codec-headers-${NV_CODEC_TAG} && make && make install

# make vmaf
RUN cd /vmaf && make clean && make
# when disabling NVCC, libvmaf will be built without cubin's which will compile kernels at start of the container
RUN cd /vmaf && make clean && make ENABLE_NVCC=true && make install

# install python tools
RUN pip3 install --no-cache-dir -r /vmaf/python/requirements.txt
Expand Down
46 changes: 0 additions & 46 deletions Dockerfile.cuda

This file was deleted.

29 changes: 29 additions & 0 deletions Dockerfile.ffmpeg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM vmaf

RUN apt-get update && \
apt-get install -y pkg-config

ARG FFMPEG_TAG=master
ARG NVCC_FLAGS="-gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -O2"

# get ffmpeg
RUN wget https://github.com/FFmpeg/FFmpeg/archive/${FFMPEG_TAG}.zip && unzip ${FFMPEG_TAG}.zip

RUN cd FFmpeg-${FFMPEG_TAG} && ./configure \
--enable-libnpp \
--enable-nonfree \
--enable-nvdec \
--enable-nvenc \
--enable-cuvid \
--enable-cuda \
--enable-cuda-nvcc \
--enable-libvmaf \
--enable-ffnvcodec \
--disable-stripping \
--nvccflags="${NVCC_FLAGS}" && \
make -j && \
make install

RUN mkdir /data
# VMAF+decode GPU (only works for NVDec supported formats https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new)
ENTRYPOINT ["ffmpeg"]
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ NINJA := $(VIRTUAL_ENV_PATH)/ninja
BUILDTYPE_RELEASE := --buildtype release
BUILDTYPE_DEBUG := --buildtype debug
ENABLE_FLOAT := -Denable_float=true
ENABLE_NVCC := true
ENABLE_CUDA := -Denable_cuda=true -Denable_nvcc=$(ENABLE_NVCC)

# Directories
LIBVMAF_DIR := libvmaf
Expand All @@ -30,10 +32,10 @@ default: build
all: build debug install test cythonize

$(BUILD_DIR): $(MESON) $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(BUILD_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_RELEASE) $(ENABLE_FLOAT)
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(BUILD_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_RELEASE) $(ENABLE_FLOAT) $(ENABLE_CUDA)

$(DEBUG_DIR): $(MESON) $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(DEBUG_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_DEBUG) $(ENABLE_FLOAT)
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(DEBUG_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_DEBUG) $(ENABLE_FLOAT) $(ENABLE_CUDA)

cythonize: cythonize-deps
pushd python && ../$(VENV_PYTHON) setup.py build_ext --build-lib . && popd || exit 1
Expand Down
1 change: 1 addition & 0 deletions libvmaf/include/libvmaf/libvmaf_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef __VMAF_CUDA_H__
#define __VMAF_CUDA_H__

#include "ffnvcodec/dynlink_cuda.h"
#include "libvmaf/libvmaf.h"

#ifdef __cplusplus
Expand Down
5 changes: 5 additions & 0 deletions libvmaf/meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ option('enable_nvtx',
type: 'boolean',
value: false,
description: 'Enable NVTX range support')

option('enable_nvcc',
type: 'boolean',
value: true,
description: 'Use clang to compile CUDA code.')
Loading
Loading