https://github.com/TNTwise/REAL-Video-Enhancer/wiki/Convert-Rife-Models
ncnn implementation of RIFE, Real-Time Intermediate Flow Estimation for Video Frame Interpolation.
rife-ncnn-vulkan uses ncnn project as the universal neural network inference framework.
Download Windows/Linux/MacOS Executable for Intel/AMD/Nvidia GPU
https://github.com/nihui/rife-ncnn-vulkan/releases
This package includes all the binaries and models required. It is portable, so no CUDA or PyTorch runtime environment is needed :)
RIFE (Real-Time Intermediate Flow Estimation for Video Frame Interpolation)
https://github.com/hzwer/arXiv2020-RIFE
Huang, Zhewei and Zhang, Tianyuan and Heng, Wen and Shi, Boxin and Zhou, Shuchang
https://arxiv.org/abs/2011.06294
Input two frame images, output one interpolated frame image.
./rife-ncnn-vulkan -0 0.jpg -1 1.jpg -o 01.jpg
./rife-ncnn-vulkan -i input_frames/ -o output_frames/
Example below runs on CPU, Discrete GPU, and Integrated GPU all at the same time. Uses 2 threads for image decoding, 4 threads for one CPU worker, 4 threads for another CPU worker, 2 threads for discrete GPU, 1 thread for integrated GPU, and 4 threads for image encoding.
./rife-ncnn-vulkan -i input_frames/ -o output_frames/ -g -1,-1,0,1 -j 2:4,4,2,1:4
mkdir input_frames
mkdir output_frames
# find the source fps and format with ffprobe, for example 24fps, AAC
ffprobe input.mp4
# extract audio
ffmpeg -i input.mp4 -vn -acodec copy audio.m4a
# decode all frames
ffmpeg -i input.mp4 input_frames/frame_%08d.png
# interpolate 2x frame count
./rife-ncnn-vulkan -i input_frames -o output_frames
# encode interpolated frames in 48fps with audio
ffmpeg -framerate 48 -i output_frames/%08d.png -i audio.m4a -c:a copy -crf 20 -c:v libx264 -pix_fmt yuv420p output.mp4
Usage: rife-ncnn-vulkan -0 infile -1 infile1 -o outfile [options]...
rife-ncnn-vulkan -i indir -o outdir [options]...
-h show this help
-v verbose output
-0 input0-path input image0 path (jpg/png/webp)
-1 input1-path input image1 path (jpg/png/webp)
-i input-path input image directory (jpg/png/webp)
-o output-path output image path (jpg/png/webp) or directory
-n num-frame target frame count (default=N*2)
-s time-step time step (0~1, default=0.5)
-m model-path rife model path (default=rife-v2.3)
-g gpu-id gpu device to use (-1=cpu, default=auto) can be 0,1,2 for multi-gpu
-j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu
-x enable spatial tta mode
-z enable temporal tta mode
-u enable UHD mode
-f pattern-format output image filename pattern format (%08d.jpg/png/webp, default=ext/%08d.png)
input0-path
,input1-path
andoutput-path
accept file pathinput-path
andoutput-path
accept file directorynum-frame
= target frame counttime-step
= interpolation timeload:proc:save
= thread count for the three stages (image decoding + rife interpolation + image encoding), using larger values may increase GPU usage and consume more GPU memory. You can tune this configuration with "4:4:4" for many small-size images, and "2:2:2" for large-size images. The default setting usually works fine for most situations. If you find that your GPU is hungry, try increasing thread count to achieve faster processing.pattern-format
= the filename pattern and format of the image to be output, png is better supported, however webp generally yields smaller file sizes, both are losslessly encoded
If you encounter a crash or error, try upgrading your GPU driver:
- Intel: https://downloadcenter.intel.com/product/80939/Graphics-Drivers
- AMD: https://www.amd.com/en/support
- NVIDIA: https://www.nvidia.com/Download/index.aspx
- Download and setup the Vulkan SDK from https://vulkan.lunarg.com/
- For Linux distributions, you can either get the essential build requirements from package manager
dnf install vulkan-headers vulkan-loader-devel
apt-get install libvulkan-dev
pacman -S vulkan-headers vulkan-icd-loader
- Clone this project with all submodules
git clone https://github.com/nihui/rife-ncnn-vulkan.git
cd rife-ncnn-vulkan
git submodule update --init --recursive
- Build with CMake
- You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS
mkdir build
cd build
cmake ../src
cmake --build . -j 4
model | upstream version |
---|---|
rife | 1.2 |
rife-HD | 1.5 |
rife-UHD | 1.6 |
rife-anime | 1.8 |
rife-v2 | 2.0 |
rife-v2.3 | 2.3 |
rife-v2.4 | 2.4 |
rife-v3.0 | 3.0 |
rife-v3.1 | 3.1 |
rife-v4 | 4.0 |
rife-v4.1 | 4.1 |
rife-v4.2 | 4.2 |
rife-v4.3 | 4.3 |
rife-v4.4 | 4.4 |
rife-v4.5 | 4.5 |
rife-v4.6 | 4.6 |
rife-v4.7 | 4.7 |
rife-v4.8 | 4.8 |
rife-v4.9 | 4.9 |
rife-v4.10 | 4.10 |
rife-v4.11 | 4.11 |
rife-v4.12 | 4.12 |
rife-v4.12-lite | 4.12-lite |
rife-v4.13 | 4.13 |
rife-v4.13-lite | 4.13-lite |
rife-ncnn-vulkan.exe -m models/rife-v4.12 -0 0.png -1 1.png -o out.png
rife-ncnn-vulkan.exe -m models/rife-anime -0 0.png -1 1.png -o out.png
rife-ncnn-vulkan.exe -m models/rife-anime -x -0 0.png -1 1.png -o out.png
- https://github.com/Tencent/ncnn for fast neural network inference on ALL PLATFORMS
- https://github.com/webmproject/libwebp for encoding and decoding Webp images on ALL PLATFORMS
- https://github.com/nothings/stb for decoding and encoding image on Linux / MacOS
- https://github.com/tronkko/dirent for listing files in directory on Windows
- https://github.com/styler00dollar/VapourSynth-RIFE-ncnn-Vulkan for the added models