Imported Debian version 1.0~trusty
[deb_vid.stab.git] / README.md
CommitLineData
80f575fc
DM
1#VidStab
2
3Vidstab is a video stabilization library which can be plugged-in with Ffmpeg and Transcode.
4
5**Why is it needed**
6
7A video acquired using a hand-held camera or a camera mounted on a vehicle, typically suffers from undesirable shakes and jitters. Activities such as surfing, skiing, riding and walking while shooting videos are especially prone to erratic camera shakes. Vidstab targets these video contents to help create smoother and stable videos.
8
9**Some of the features include:**
10
11 * Fast detection of subsequent transformations e.g. translation and rotations up to a given extent.
12 * Low pass filtered smoothing with adjustable horizon.
13 * Detection algorithms:
14 * Smart and fast multi measurement fields algorithm with contrast selection.
15 * Brute force algorithm only for translations.
16 * Clipping options: keep blank (black) or keep from previous frames.
17 * Optional drawing of measurement fields and detected transformations for visual analysis.
18 * Zooming possible to get rid of jiggling borders (automatic mode).
19 * Resulting images are interpolated (different algorithms).
20 * Sharpening of the stabilized movie to compensate for interpolation effects due to rotation/zooming (only with Transcode).
21 * Single pass filter for streaming applications(only with Transcode).
22 * Virtual-tripod-mode to get a tripod experience.
23
24**NOTE:** This readme focuses mainly on using vidstab with Ffmpeg. See
25[here](http://public.hronopik.de/vid.stab) for information regarding installation, usage and examples for using vidstab with Transcode. Or contact me at georg dot martius @ web dot de
26
27##System Requirements
28 * A Linux-based system
29 * ffmpeg source code
30 * Cmake
31
32##Installation Instructions
33
34For using vidstab library with ffmpeg, ffmpeg must to be configured using `--enable-libvidstab ` option.
35
36###Default Build and Installation:
37#####Installing vidstab library:
38
39```shell
40cd path/to/vid.stab/dir/
41cmake .
42make
43sudo make install
44```
45
46#####Installing ffmpeg:
47
48```shell
49cd path/to/ffmpeg/dir/
50./configure --enable-gpl --enable-libvidstab <other configure options>
51make
52sudo make install
53```
54
55###Alternatively one can install vidstab into a custom directory this way:
56#####Installing vidstab library:
57
58```shell
59cd path/to/vid.stab/dir/
60cmake -DCMAKE_INSTALL_PREFIX:PATH=path/to/install_dir/
61make
62sudo make install
63```
64
65#####Installing ffmpeg:
66
67```shell
68cd path/to/ffmpeg/dir/
69PKG_CONFIG_PATH="path/to/install_dir/lib/pkgconfig" \
70./configure --enable-gpl --enable-libvidstab <other optionalconfigure options>
71make
72sudo make install
73```
74
75Before running ffmpeg for the first time, make sure to export `LD_LIBRARY_PATH` to point to vidstab library, e.g.,
76
77```shell
78export LD_LIBRARY_PATH=path/to/install_dir/lib:$LD_LIBRARY_PATH
79```
80
81##Usage instructions
82
83**Currently with ffmpeg, vidstab library must run in two-pass mode.** The first pass employs the **vidstabdetect** filter and the second pass uses the **vidstabtransform** filter.
84
85*Single pass filter with vidstab library is only available with Transcode. The
86[deshake](http://www.ffmpeg.org/ffmpeg-filters.html#deshake) filter of ffmpeg can be used for a single-pass encoding, though using the vidstab two-pass filters will give superior results.*
87
88The vidstabdetect filter (in first pass) will generate a file with relative-translation and rotation-transform information about subsequent frames. This information will then be read by vidstabtransform filter (in second pass) to compensate for the jerky motions and produce a stable video output.
89
90Make sure that you use [unsharp](http://www.ffmpeg.org/ffmpeg-filters.html#unsharp-1) filter provided by ffmpeg for best results (only in second pass).
91
92*See [the list of ffmpeg filters](http://www.ffmpeg.org/ffmpeg-filters.html) to know more about vidstabdetect, vidstabtransform and all other filters available with ffmpeg.*
93
94###Available options with vidstab filters:
95
96#####First pass (vidstabdetect filter):
97
98<dl>
99 <dt><b>result</b></dt>
100 <dd>Set the path to the file used to write the transforms information. Default value is <b>transforms.trf</b>.</dd>
101 <dt><b>shakiness</b></dt>
102 <dd>Set the shakiness of input video or quickness of camera. It accepts an integer in the range 1-10, a value of 1 means little shakiness, a value of 10 means strong shakiness. Default value is 5.</dd>
103 <dt><b>accuracy</b></dt>
104 <dd>Set the accuracy of the detection process. It must be a value in the range 1-15. A value of 1 means low accuracy, a value of 15 means high accuracy. Default value is 15.</dd>
105 <dt><b>stepsize</b></dt>
106 <dd>Set stepsize of the search process. The region around minimum is scanned with 1 pixel resolution. Default value is 6.</dd>
107 <dt><b>mincontrast</b></dt>
108 <dd>Set minimum contrast. Any measurement field having contrast below this value is discarded. Must be a floating point value in the range 0-1. Default value is 0.3.</dd>
109 <dt><b>tripod</b></dt>
110 <dd> Set reference frame number for tripod mode. If enabled, the motion of the frames is compared to a reference frame in the filtered stream, identified by the specified number. The intention is to compensate all movements in a more-or-less static scene and keep the camera view absolutely still. If set to 0, it is disabled. The frames are counted starting from 1.
111 <br>NOTE: If this mode is used in first pass then it should also be used in second pass.</dd>
112 <dt><b>show</b></dt>
113 <dd>Show fields and transforms in the resulting frames for visual analysis. It accepts an integer in the range 0-2. Default value is 0, which disables any visualization.</dd>
114</dl>
115
116
117
118#####Examples:
119 Use default values:
120```shell
121ffmpeg -i input.mp4 -vf vidstabdetect -f null -
122```
123
124 *` -f null - ` makes sure that no output is produced as this is just the first pass. This in-turn results in faster speed.*
125
126 Analyzing strongly shaky video and putting the results in file `mytransforms.trf`:
127```shell
128ffmpeg -i input.mp4 -vf vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf" -f null -
129```
130
131 Visualizing the result of internal transformations in the resulting video:
132```shell
133ffmpeg -i input.mp4 -vf vidstabdetect=show=1 dummy_output.mp4
134```
135
136 Analyzing a video with medium shakiness:
137```shell
138ffmpeg -i input.mp4 -vf vidstabdetect=shakiness=5:show=1 dummy_output.mp4
139```
140
141#####Second pass (vidstabtransform filter):
142<dl>
143 <dt><b>input</b></dt>
144 <dd>Set path to the file used to read the transforms. Default value is <b>transforms.trf</b>.</dd>
145 <dt><b>smoothing</b></dt>
146 <dd>Set the number of frames (value*2 + 1), used for lowpass filtering the camera movements. Default value is 10.<br>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 value leads to a smoother video, but limits the acceleration of the camera (pan/tilt movements). 0 is a special case where a static camera is simulated.</dd>
147 <dt><b>optalgo</b></dt>
148 <dd>Set the camera path optimization algorithm. Accepted values are:
149 <br><i><b>gauss:</b></i> Gaussian kernel low-pass filter on camera motion (default).
150 <br><i><b>avg:</b></i> Averaging on transformations.</dd>
151 <dt><b>maxshift</b></dt>
152 <dd>Set maximal number of pixels to translate frames. Default value is -1, meaning: no limit.</dd>
153 <dt><b>maxangle</b></dt>
154 <dd>Set maximal angle in radians (degree*PI/180) to rotate frames. Default value is -1, meaning: no limit.</dd>
155 <dt><b>crop</b></dt>
156 <dd> Specify how to deal with empty frame borders that may be shrinked-in due to movement compensation. Available values are:
157 <br><i><b>keep</b></i>: Keep image information from previous frame (default).
158 <br><i><b>black</b></i>: Fill the border-areas black.</dd>
159 <dt><b>invert</b></dt>
160 <dd>Invert transforms if set to 1. Default value is 0.</dd>
161 <dt><b>relative</b></dt>
162 <dd>Consider transforms as relative to previous frame if set to 1, absolute if set to 0. Default value is 0.</dd>
163 <dt><b>zoom</b></dt>
164 <dd>Set percentage to zoom. A positive value will result in a zoom-in effect, a negative value in a zoom-out effect. Default value is 0 (no zoom).</dd>
165 <dt><b>optzoom</b></dt>
166 <dd>Set optimal zooming to avoid blank-borders. Accepted values are:
167 <br><i><b>0</b></i>: Disabled.
168 <br><i><b>1</b></i>: Optimal static zoom value is determined (only very strong movements will lead to visible borders) (default).
169 <br><i><b>2</b></i>: Optimal adaptive zoom value is determined (no borders will be visible), see <b>zoomspeed</b>.
170 <br>Note that the value given at zoom is added to the one calculated here.</dd>
171 <dt><b>zoomspeed</b></dt>
172 <dd>Set percent to zoom maximally each frame (enabled when optzoom is set to 2). Range is from 0 to 5, default value is 0.25.</dd>
173 <dt><b>interpol</b></dt>
174 <dd>Specify type of interpolation. Available values are:
175 <br><i><b>no</b></i>: No interpolation.
176 <br><i><b>linear</b></i>: Linear only horizontal.
177 <br><i><b>bilinear</b></i>: Linear in both directions (default).
178 <br><i><b>bicubic</b></i>: Cubic in both directions (slow speed).
179 <dt><b>tripod</b></dt>
180 <dd>Enables virtual tripod mode if set to 1, which is equivalent to <b>relative=0:smoothing=0</b>. Default value is 0.
181 <br>NOTE: If this mode has been used in first pass then only it should be used in second pass.</dd>
182 <dt><b>debug</b></dt>
183 <dd>Increase log verbosity if set to 1. Also the detected global motions are written to the temporary file <b>global_motions.trf</b> . Default value is 0. </dd>
184
185</dl>
186
187#####Examples:
188 Using default values:
189```shell
190ffmpeg -i input.mp4 -vf vidstabtransform,unsharp=5:5:0.8:3:3:0.4 out_stabilized.mp4
191```
192Note the use of the ffmpeg's unsharp filter which is always recommended.
193
194
195Zooming-in a bit more and load transform data from a given file:
196```shell
197ffmpeg -i input.mp4 -vf vidstabtransform=zoom=5:input="mytransforms.trf" out_stabilized.mp4
198```
199
200Smoothening the video even more:
201```shell
202ffmpeg -i input.mp4 -vf vidstabtransform=smoothing=30:input="mytransforms.trf" out_stabilized.mp4
203```
204##Developement/Contributing
205
206Vidstab is an open source library - pull requests are very welcome. Some things you might like to help us out with:
207
208 * Specific video clips where vidstab is not up-to the mark.
209 * Bugs/fixes.
210 * New features and improvements.
211 * Documentation.
212
213
214## License
215
216See [LICENSE](./LICENSE).