This example shows how to increase a video's frame rate using optical flow frame interpolation. A video is subsampled to simulate a jerky low-frame-rate input, then new intermediate frames are interpolated using RAFT optical flow to restore smooth motion.
MATLAB® is required along with Computer Vision Toolbox™.
- MATLAB® R2024b or later
- Computer Vision Toolbox™
- Computer Vision Toolbox™ Model for RAFT Optical Flow (support package)
Run the example script:
IncreaseVideoFrameRateUsingOpticalFlowOr use temporalUpsample directly on your own video:
% Interpolate frames to 4x the original frame rate
output = temporalUpsample(frames, 4);
% Interpolate using Farneback (no support package needed)
output = temporalUpsample("myVideo.mp4", 2, Method="farneback");
% Use GPU acceleration
output = temporalUpsample(frames, 3, ExecutionEnvironment="GPU");The temporalUpsample function performs frame interpolation by:
- Computing bidirectional optical flow between each pair of consecutive frames using RAFT (or Farneback)
- Forward-splatting pixels from both neighboring frames to each intermediate time position
- Using exponential importance weighting so moving objects dominate over static background at contested destinations
- Blending the two contributions with occlusion-aware temporal weighting
- Filling any remaining holes with local median filtering
| File | Description |
|---|---|
temporalUpsample.m |
Main function — interpolate frames to increase video frame rate |
IncreaseVideoFrameRateUsingOpticalFlow.m |
Example script with side-by-side comparison |
This implementation uses techniques from the following papers:
- Niklaus, S. and Liu, F. "Softmax Splatting for Video Frame Interpolation." CVPR, 2020. (forward splatting with importance weighting)
- Teed, Z. and Deng, J. "RAFT: Recurrent All-Pairs Field Transforms for Optical Flow." ECCV, 2020. (optical flow estimation)
Copyright 2025 The MathWorks, Inc. See license.txt for details.
