Developement of Cuda based Tonemapping filter for ffmpeg

Hey guys!

Wanted to post/begin a thread sharing my progress on building a cuda based ffmpeg filter designed to enable tonemaping of HDR content to an HDR colour space. It’s part of a personal project to build a distributed compute cluster for handling load balancing and serving of multimedia to different clients, all in as efficient a package as possible.

the procedure for testing this is at the bottom, but essentially I’ve modified the ffmpeg kernel.

it’s very much a bodge and proof of concept, but should work. As of now it’s performing reinhard tonemapping (pixel = pxiel* (pixel/(pixel+1)))

This should be adjustable to suit any global curve algorithm extremely easily (hable, clip etc.)

I havent gotten my nano in (waiting to see if I can get a TX2 edu discount since it should be more powerful per dollar and student budget…)

for those interested in the overall project, the repo is here:

syntax will be:
ffmpeg -i INPUT -i INPUT -filter_complex 'hwupload_cuda,overlay_cuda' OUTPUT

    This is a bodge for now, since it's only modifying the output of the cuda kernel itself

    to use it, replace ffmpeg/libavfilter/ with this file:

It compiles fine, but can't test without a nano for actual usage.

will require to self build:

git init 

git fetch

cd ffmpeg && make clean

./configure --enable-nonfree --enable-cuda

    mv ~/path/to/this_version_of/ ~/path/to/ffmpeg/libavfilter/

    make -j

    //get coffee

    ffmpeg -i INPUT -i INPUT -filter_complex 'hwupload_cuda,overlay_cuda' OUTPUT

    ffplay output

    is output different?

    test file:
1 Like

Thanks for the sharing. This provides another alternative for users who needs video encoding/decoding on Jetson platforms.

Update! The bodge used in Post 1 is no longer required!

please proceed as before but with vf_tonemap_cuda.c and .cu. you’ll need the nvidia headers and to add vf_tonemap_cuda to the relevant files in the filters Makefile as well as the configuration script. fffmpeg/doc/writing_filters.txt contains all the relevant documentation for adding new filters. I’m waiting on the powers that be to upstream the new filter (which will mean all cuda platforms will have access to it)

This is part of a larger project for creating a distributed multimedia compute cluster with idle power draw lower than 10w that peaks at no more than 100w!