Automatically finds and fixes lags in video recordings by detecting duplicate frames and interpolating only the laggy sections using RIFE.
Note: his tool is not a magic bullet. While interpolating large freeze frames in low-motion areas works, high-motion segments with long freezes are difficult to restore.
- Naive full-video interpolation amplifies lags. This tool detects laggy regions and interpolates only those, which both reduces amplified lag and is faster than naive RIFE.
- Motion compensation interpolates more frames than were detected as duplicates to avoid the interpolated segment appearing slower.
- Uses RIFE-NCNN-Vulkan for interpolation.
Basic example:
./target/release/video_lag_fix -i input.mp4 -o output.mp4- Perceptual hashing to quickly filter obviously unique frames.
tiny_duplicate_netclassifier for robust duplicate detection (more resistant to artifacts).tiny_motion_netregressor to decide the interpolation window by estimating global absolute motion magnitude.- RIFE interpolates intermediate frames.
- Patch interpolated frames back into the video.
compare_recode.mp4
Left: Laggy video, Right: Fixed video (both slowed by 50%)
-i <path>input file-o <path>output file-m <path>RIFE model path relative to the rife binary--find-onlydetect duplicates only, do not patch video--render-hwaccelffmpeg hardware accel backend (defaultcuda)--render-argsffmpeg output args (must be changed for non-CUDA hardware or different codecs)--max-motion-mulmaximum multiple of the background average motion allowed to still interpolate (default 7.3). Higher values allow more motion to be interpolated; lower values restrict high-motion interpolation. Range: 1.0..
git clone --recursive https://github.com/redstonemedia/video_lag_fix.git
cd video_lag_fix
cargo build --release --binsYou will also need to follow the build instructions for rife-ncnn-vulkan.
The rife binary is expected in rife-ncnn-vulkan/build.
