How to Adjust FFmpeg Deshake Search Range

This article explains how to adjust the motion detection search range in the FFmpeg deshake video stabilization filter. You will learn which parameters control the search radius and search methodology, along with practical command-line examples to optimize your video stabilization process.

The FFmpeg deshake filter works by comparing blocks of pixels between frames to estimate camera motion. To adjust how far the filter looks to detect this shaking, you need to configure the search range parameters: rx and ry.

Key Parameters for Search Range

Practical Command Examples

To adjust these settings, pass the parameters directly to the deshake filter in your FFmpeg command.

1. Increasing the Search Range for Heavy Shaking

If your video has significant, wide-angle camera shakes, you should increase the search range to the maximum value of 64 pixels:

ffmpeg -i input.mp4 -vf "deshake=rx=64:ry=64" output.mp4

2. Decreasing the Search Range for Micro-vibrations

For high-frequency, small-amplitude vibrations (like drone footage or tripod vibrations), decrease the search range to save processing power and prevent false motion detection:

ffmpeg -i input.mp4 -vf "deshake=rx=8:ry=8" output.mp4

To combine a larger search range with the most accurate detection method, set the search parameter to 0 (exhaustive search):

ffmpeg -i input.mp4 -vf "deshake=rx=32:ry=32:search=0" output.mp4

Tips for Best Results