21 #define DEFAULT_RESULT_NAME "transforms.trf"
23 #include <vid.stab/libvidstab.h>
44 #define OFFSET(x) offsetof(StabData, x)
45 #define OFFSETC(x) (offsetof(StabData, conf)+offsetof(VSMotionDetectConfig, x))
46 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
50 {
"shakiness",
"how shaky is the video and how quick is the camera?"
53 {
"stepsize",
"region around minimum is scanned with 1 pixel resolution",
OFFSETC(stepSize),
AV_OPT_TYPE_INT, {.i64 = 6}, 1, 32,
FLAGS},
56 {
"tripod",
"virtual tripod mode (if >0): motion is compared to a reference"
67 sd->
class = &vidstabdetect_class;
75 VSMotionDetect *
md = &(sd->
md);
82 vsMotionDetectionCleanup(md);
105 VSMotionDetect*
md = &(sd->
md);
109 vsFrameInfoInit(&fi, inlink->
w, inlink->
h,
112 av_log(ctx,
AV_LOG_ERROR,
"pixel-format error: wrong bits/per/pixel, please report a BUG");
127 sd->
conf.modName =
"vidstabdetect";
128 if (vsMotionDetectInit(md, &sd->
conf, &fi) != VS_OK) {
129 av_log(ctx,
AV_LOG_ERROR,
"initialization of Motion Detection failed, please report a BUG");
133 vsMotionDetectGetConfig(&sd->
conf, md);
143 sd->
f = fopen(sd->
result,
"w");
148 if (vsPrepareFile(md, sd->
f) != VS_OK) {
160 VSMotionDetect *
md = &(sd->
md);
161 LocalMotions localmotions;
170 for (plane = 0; plane < md->fi.planes; plane++) {
171 frame.data[plane] = in->
data[plane];
172 frame.linesize[plane] = in->
linesize[plane];
174 if (vsMotionDetection(md, &localmotions, &frame) != VS_OK) {
178 if (vsWriteToFile(md, sd->
f, &localmotions) != VS_OK) {
182 vs_vector_del(&localmotions);
207 .
name =
"vidstabdetect",
209 "pass 1 of 2 for stabilization "
210 "(see vidstabtransform for pass 2)."),
215 .
inputs = avfilter_vf_vidstabdetect_inputs,
216 .
outputs = avfilter_vf_vidstabdetect_outputs,
217 .priv_class = &vidstabdetect_class,