Written by me@grafxflow
18 Dec, 2025
0
938
FFmpeg can stabilise a video utilising a two-pass method. The aim of my entry is to compile some references and commands that I have found beneficial, primarily for my future reference.
The initial step employs vidstabdetect to examine the video and generate stabilisation data, which is saved in a file named transforms.trf. Various parameters, including shakiness, accuracy, and stepsize, can be adjusted to indicate the level of shakiness in the video, the required precision of the detection process, and the detection step size. The default settings are satisfactory for my needs.
# Example given in the docs to analyse very shaky video.
ffmpeg -i original_video.mkv -vf vidstabdetect=shakiness=10:accuracy=15 -f null -
# Example using the default parameter values.
ffmpeg -i original_video.mkv -vf vidstabdetect -f null -
The second pass employs vidstabtransform, which processes the file generated in the first pass to produce a stabilised video. This filter includes numerous parameters for adjusting smoothing, interpolation, and zooming. I prefer to use the default settings, which yield satisfactory results. FFmpeg recommends utilising this step in conjunction with the unsharp video filter.
# Example to use the default .trf file generated to stabilise a video.
ffmpeg -i original_video.mkv -vf vidstabtransform stabilised_original_video.mkv
Combining both passes
By merging the two passes into one command, we arrive at the command listed below.
export vid="original_video.mkv"
ffmpeg -i "$vid" -vf vidstabdetect -f null -; ffmpeg -i "$vid" -vf vidstabtransform "stabilised_$vid"
21 Sep, 2012
02 Sep, 2012
20 May, 2025
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!
Follow18 Dec, 2025
20 May, 2025
11 Jul, 2023
Views: 247,331
Views: 246,868
Views: 175,026
Views: 146,112