Skip to main content
Working from scratch, following simplicity

How to stabilize a video using FFmpeg and vid.stab

Recently I have refurbished my HTC Re Camera, an old instant camera, because I wanted to make some videos. The results were very devastating: I discovered that I have a shaky hand! Fortunately there are FFmpeg and vid.stab that helped me to stabilize them. In this post I explain how to install this plugin and use it, then showing two comparison videos.

HTC Re Camera was an excellent instant camera (produced by the 2014 and now out of production) with the portability as trump card. Furthermore it has a video stabilization but it doesn't help as much when I am running or walking. So I needed to remove the shaking from my videos.

As usual Internet had already a solution and its name is vidstab an optional library for FFmpeg1 or Transcode2 . The library can stabilize and smooth out shaky video on Linux. Below there is a summary and my adaptation of two awesome articles that have solved my problem:

  1. Video Stabilization Using VidStab and FFmpeg on Linux
  2. Stabilizing GoPro Video with FFmpeg and vid.stab
How to stabilize a video using FFmpeg and vid.stab


In Ubuntu 18.04, FFmpeg has not enabled vidstab, so you can compile it or better use an FFmpeg static build from here which has vid.stab enabled: FFmpeg Static Builds. I download it according to my system, extract it in a directory and linked in a bash script that has inside all the needed settings.

Stabilization Commands

There are many combination and choices, I report the options that I use, called: one step and two steps. In the first FFmpeg doesn't analyze the video stream, it is more fast but the quality is better in the second.

One step

ffmpeg -i input.mp4 -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 output.mp4

Two steps

ffmpeg -i input.mp4 -vf vidstabdetect=stepsize=32:shakiness=10:accuracy=10:result=transforms.trf -f null -
ffmpeg -y -i input.mp4 -vf vidstabtransform=input=transforms.trf:zoom=0:smoothing=10,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -tune film -acodec copy -preset slow output.mp4

Finally this is the script that I usually launch inside the directory with the video files3 :

# Sources:


if [ -z "$1" ]
        echo "Usage:" 
        echo  " filename.mp4"
        exit 0

# one step
$path/ffmpeg -y -i $1 \
      -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 ${1%.*}_oneStep.mp4

# two steps
$path/ffmpeg -y -i $1 \
      -vf vidstabdetect=stepsize=32:shakiness=10:accuracy=10:result=transforms.trf -f null -
$path/ffmpeg -y -i $1 \
      -vf vidstabtransform=input=transforms.trf:zoom=0:smoothing=10,unsharp=5:5:0.8:3:3:0.4 \
      -vcodec libx264 -tune film -acodec copy -preset slow  \


The first example is a panoramic view of a rose:

The second one is a short running:

  • 1FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. Site:
  • 2transcode is the LINUX video stream processing tool. More info here:
  • 3In order to do that you can set permanently a path that contains your scripts, you have only to add to your ~/.profile or ~/.bashrc file this code: export PATH="$PATH:/path/to/dir

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Sponsored Links

Nicola Rainiero

A civil geotechnical engineer with the ambition to facilitate own work with free software for a knowledge and collective sharing. Also, I deal with green energy and in particular shallow geothermal energy. I have always been involved in web design and 3D modelling.