How to stabilize a video using ffmpeg
Table of Contents
In this short tutorial you will learn how to use ffmpeg and the vidstab library to stabilize a video in two simple commands.
The stabilizing process has two steps: analizing and processing.
Analize the video
ffmpeg -i <input file> -vf vidstabdetect -f null <temp file>
<temp file>is where the information about the video is saved for the next step. You can name it whatever you want (it’s usually called ‘transforms.trf’).- More parameters.
Process the video
ffmpeg -i <input file> -vf vidstabtransform=smoothing=5:input=<temp file> <output file>
smoothing: Set the number of frames (value*2 + 1) used for lowpass filtering the camera movements. Default value is 10.inputis optional if you usetransforms.trf.- More parameters.
Example (script)
#!/bin/bash
INPUT=$1
OUTPUT=$2
TEMP="transforms.trf"
ffmpeg -i $INPUT -vf vidstabdetect -f null $TEMP
ffmpeg -i $INPUT -vf vidstabtransform=smoothing=5:input=$TEMP $OUTPUT If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: