Adjust vidstabdetect Accuracy in FFmpeg

This article provides a quick guide on how to adjust the shaking detection accuracy in FFmpeg using the vidstabdetect filter. By fine-tuning parameters such as accuracy, shakiness, and step size, you can significantly improve how the filter analyzes camera movement, leading to much smoother video stabilization in the subsequent rendering step.

The vidstabdetect filter is the first step in the two-pass stabilization process of the vid.stab library in FFmpeg. It analyzes the video and writes motion data to a file (typically transforms.trf). To adjust how precisely this filter detects shaking, you need to modify three key parameters: accuracy, shakiness, and stepsize.

Key Parameters for Adjusting Accuracy

Example Commands

To apply these adjustments, run the detection pass with your custom parameters.

For Highly Precise Detection (Slowest, Best Quality):

ffmpeg -i input.mp4 -vf vidstabdetect=accuracy=15:shakiness=8:stepsize=2:result=transforms.trf -f null -

For Standard/Default Detection (Balanced):

ffmpeg -i input.mp4 -vf vidstabdetect=accuracy=10:shakiness=4:stepsize=6:result=transforms.trf -f null -

The Second Pass (Applying the Stabilization)

Once the motion data is generated with your desired accuracy settings, apply the stabilization using the vidstabtransform filter in the second pass:

ffmpeg -i input.mp4 -vf vidstabtransform=input=transforms.trf output.mp4