Skip to content

how‐to‐build‐cartwheel‐ffmpeg‐Video‐Super‐Resolution‐Library

FocusLuo edited this page Mar 21, 2024 · 2 revisions

How to build ffmpeg Video-Super-Resolution-Library

install Video-Super-Resolution-Library

Install libva

$ apt-get install libva-dev intel-media-va-driver-non-free

Install opencl runtime

You can download latest OpenCL runtime: compute-runtime

command example:

$ apt-get install intel-opencl-icd libopencv-dev mesa-opencl-icd ocl-icd-opencl-dev opencl-headers
$ wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.13700.14/intel-igc-core_1.0.13700.14_amd64.deb \
  && wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.13700.14/intel-igc-opencl_1.0.13700.14_amd64.deb \
  && wget https://github.com/intel/compute-runtime/releases/download/23.13.26032.30/intel-level-zero-gpu_1.3.26032.30_amd64.deb \
  && wget https://github.com/intel/compute-runtime/releases/download/23.13.26032.30/intel-opencl-icd_23.13.26032.30_amd64.deb \
  && wget https://github.com/intel/compute-runtime/releases/download/23.13.26032.30/libigdgmm12_22.3.0_amd64.deb \
$ dpkg -i *.deb

command example:

$ git clone https://github.com/intel/cartwheel-ffmpeg.git
$ cd cartwheel-ffmpeg
$ git checkout raisr4nas
$ git clone https://github.com/OpenVisualCloud/Video-Super-Resolution-Library.git
$ cd Video-Super-Resolution-Library
$ git am ../Video-Super-Resolution-Library-patches/*.patch

Enable GPU and build

$ ./build.sh -DENABLE_RAISR_CPU=OFF -DENABLE_RAISR_OPENCL=ON -DCMAKE_INSTALL_PREFIX=$ROOT_INSTALL_DIR
$ cd ..

Or it can detect OpenCL package and enable RAISR_OPENCL automatically

$ ./build.sh -DENABLE_RAISR_CPU=OFF -DCMAKE_INSTALL_PREFIX=$ROOT_INSTALL_DIR
$ cd ..

If you need CPU acceleration please follow this guide base-toolkit-download to install IPP and build with option "-DENABLE_RAISR_CPU=ON"

Build ffmpeg with Video-Super-Resolution-Library

command example:

$ git submodule update --init --recursive
$ cd ffmpeg
$ git am ../patches/*.patch
$ ./configure --prefix=$ROOT_INSTALL_DIR --enable-libraisr --enable-opencl --enable-vaapi --extra-cflags="-fopenmp -I${ROOT_INSTALL_DIR}/include/" --extra-ldflags="-fopenmp -L${ROOT_INSTALL_DIR}/lib/" --enable-gpl 
$ make -j && make install
$ cd ..

copy filter files to your working folder

$ cp -r Video-Super-Resolution-Library/filters* ./

ffmpeg command

ffmpeg -init_hw_device vaapi=va -init_hw_device opencl=ocl@va -hwaccel vaapi -hwaccel_output_format vaapi -i input.264 -vf "hwmap=derive_device=opencl,format=opencl,raisr_opencl,hwmap=derive_device=vaapi:reverse=1:extra_hw_frames=16" -c:v hevc_vaapi output.mp4

better quality but lower spped

ffmpeg -init_hw_device vaapi=va -init_hw_device opencl=ocl@va -hwaccel vaapi -hwaccel_output_format vaapi -i input.264 -vf "hwmap=derive_device=opencl,format=opencl,raisr_opencl=passes=2,hwmap=derive_device=vaapi:reverse=1:extra_hw_frames=16" -c:v hevc_vaapi output.mp4

choose different filter

ffmpeg -init_hw_device vaapi=va -init_hw_device opencl=ocl@va -hwaccel vaapi -hwaccel_output_format vaapi -i input.264 -vf "hwmap=derive_device=opencl,format=opencl,raisr_opencl=passes=2:filterfolder='filters_2x/filters_highres',hwmap=derive_device=vaapi:reverse=1:extra_hw_frames=16" -c:v hevc_vaapi output.mp4