FFmpeg Framerate Filter Scene Change and Blending

This article explains how to use the FFmpeg framerate filter to convert video frame rates smoothly. You will learn how to configure the filter's parameters to blend frames for seamless transitions and configure scene change detection to prevent ghosting artifacts during dramatic camera cuts.

Understanding the framerate Filter

Unlike the basic fps filter, which simply drops or duplicates frames to meet a target rate, the framerate filter calculates intermediate frames using scene change detection and linear interpolation (blending). This results in a much smoother output, especially when upconverting frame rates (e.g., converting 24 fps to 60 fps).

The Basic Command Structure

To use the framerate filter, you apply the -vf (video filter) flag followed by framerate and its associated options.

ffmpeg -i input.mp4 -vf "framerate=fps=60" output.mp4

Configuring Blending and Scene Change Detection

To get the best visual results, you must fine-tune the interpolation and scene change threshold parameters.

Here is a command optimized for blending with scene change detection:

ffmpeg -i input.mp4 -vf "framerate=fps=60:interp_start=64:interp_end=192:scene=8.2" output.mp4

Parameter Breakdown:

  • fps: The target output frame rate (e.g., 60, 30, 29.97).
  • scene: The scene change detection threshold, specified as a percentage value from 0 to 100.
    • The default value is 8.2.
    • When the difference between two consecutive frames exceeds this threshold, FFmpeg identifies it as a scene change.
    • Upon detecting a scene change, the filter stops blending the frames and performs a hard cut instead. This prevents "ghosting" or "morphing" artifacts between two completely different shots.
  • interp_start and interp_end: These define the blending range using values from 0 to 255.
    • interp_start (default 15): Frames before this point are not blended.
    • interp_end (default 240): Frames after this point are not blended.
    • Setting these parameters determines the duration and intensity of the linear interpolation between frames.

Tips for Tuning the Scene Parameter

  • If you see ghosting during cuts: Your scene threshold is too high. Decrease the value (e.g., scene=5) to make the filter more sensitive to scene changes, forcing a hard cut earlier.
  • If the video is stuttering during fast action: Your scene threshold might be too low. Increase the value (e.g., scene=12) to allow blending to continue during fast motion within the same scene.