Video stabilization/deshaking: pass 2 of 2, see vidstabdetect for pass 1.
Read a file with transform information for each frame and apply/compensate them. Together with the vidstabdetect filter this can be used to deshake videos. See also http://public.hronopik.de/vid.stab. It is important to also use the unsharp filter, see below.
To enable compilation of this filter you need to configure FFmpeg with
--enable-libvidstab
.
This filter accepts the following options:
- input
-
path to the file used to read the transforms (default: transforms.trf)
- smoothing
-
number of frames (value*2 + 1) used for lowpass filtering the camera movements (default: 10). For example a number of 10 means that 21 frames are used (10 in the past and 10 in the future) to smoothen the motion in the video. A larger values leads to a smoother video, but limits the acceleration of the camera (pan/tilt movements).
- maxshift
-
maximal number of pixels to translate frames (default: -1 no limit)
- maxangle
-
maximal angle in radians (degree*PI/180) to rotate frames (default: -1 no limit)
- crop
-
How to deal with borders that may be visible due to movement compensation. Available values are:
- keep
-
keep image information from previous frame (default)
- black
-
fill the border black
- invert
-
- 0
-
keep transforms normal (default)
- 1
-
invert transforms
- relative
-
consider transforms as
- 0
-
absolute
- 1
-
relative to previous frame (default)
- zoom
-
percentage to zoom (default: 0)
- >0
-
zoom in
- <0
-
zoom out
- optzoom
-
set optimal zooming to avoid borders
- 0
-
disabled
- 1
-
optimal static zoom value is determined (only very strong movements will lead to visible borders) (default)
- 2
-
optimal adaptive zoom value is determined (no borders will be visible)
Note that the value given at zoom is added to the one calculated here.
- interpol
-
type of interpolation
Available values are:
- no
-
no interpolation
- linear
-
linear only horizontal
- bilinear
-
linear in both directions (default)
- bicubic
-
cubic in both directions (slow)
- tripod
-
virtual tripod mode means that the video is stabilized such that the camera stays stationary. Use also
tripod
option of vidstabdetect.- 0
-
off (default)
- 1
-
virtual tripod mode: equivalent to
relative=0:smoothing=0
Examples
-
typical call with default default values: (note the unsharp filter which is always recommended)
ffmpeg -i inp.mpeg -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 inp_stabilized.mpeg
-
zoom in a bit more and load transform data from a given file
vidstabtransform=zoom=5:input="mytransforms.trf"
-
smoothen the video even more
vidstabtransform=smoothing=30