21 #define DEFAULT_INPUT_NAME "transforms.trf"
23 #include <vid.stab/libvidstab.h>
44 #define OFFSET(x) offsetof(TransformContext, x)
45 #define OFFSETC(x) (offsetof(TransformContext, conf)+offsetof(VSTransformConfig, x))
46 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
49 {
"input",
"path to the file storing the transforms",
OFFSET(input),
51 {
"smoothing",
"number of frames*2 + 1 used for lowpass filtering",
OFFSETC(smoothing),
53 {
"maxshift",
"maximal number of pixels to translate image",
OFFSETC(maxShift),
55 {
"maxangle",
"maximal angle in rad to rotate image",
OFFSETC(maxAngle),
57 {
"crop",
"set cropping mode",
OFFSETC(crop),
59 {
"keep",
"keep border", 0,
61 {
"black",
"black border", 0,
63 {
"invert",
"1: invert transforms",
OFFSETC(invert),
65 {
"relative",
"consider transforms as 0: absolute, 1: relative",
OFFSETC(relative),
67 {
"zoom",
"percentage to zoom >0: zoom in, <0 zoom out",
OFFSETC(zoom),
69 {
"optzoom",
"0: nothing, 1: determine optimal zoom (added to 'zoom')",
OFFSETC(optZoom),
71 {
"interpol",
"type of interpolation",
OFFSETC(interpolType),
73 {
"no",
"no interpolation", 0,
75 {
"linear",
"linear (horizontal)", 0,
77 {
"bilinear",
"bi-linear", 0,
79 {
"bicubic",
"bi-cubic", 0,
81 {
"tripod",
"if 1: virtual tripod mode (equiv. to relative=0:smoothing=0)",
OFFSET(tripod),
92 tc->
class = &vidstabtransform_class;
101 vsTransformDataCleanup(&tc->
td);
102 vsTransformationsCleanup(&tc->
trans);
129 VSTransformData *
td = &(tc->
td);
134 if (!vsFrameInfoInit(&fi_src, inlink->
w, inlink->
h,
136 !vsFrameInfoInit(&fi_dest, inlink->
w, inlink->
h,
155 tc->
conf.modName =
"vidstabtransform";
159 tc->
conf.relative = 0;
160 tc->
conf.smoothing = 0;
163 if (vsTransformDataInit(td, &tc->
conf, &fi_src, &fi_dest) != VS_OK) {
164 av_log(ctx,
AV_LOG_ERROR,
"initialization of vid.stab transform failed, please report a BUG\n");
168 vsTransformGetConfig(&tc->
conf, td);
169 av_log(ctx,
AV_LOG_INFO,
"Video transformation/stabilization settings (pass 2/2):\n");
181 f = fopen(tc->
input,
"r");
186 VSManyLocalMotions mlms;
187 if (vsReadLocalMotionsFile(f, &mlms) == VS_OK) {
189 if (vsLocalmotions2TransformsSimple(td, &mlms, &tc->
trans) != VS_OK) {
194 if (!vsReadOldTransforms(td, f, &tc->
trans)) {
202 if (vsPreprocessTransforms(td, &tc->
trans) != VS_OK ) {
216 VSTransformData*
td = &(tc->
td);
236 for (plane = 0; plane < vsTransformGetSrcFrameInfo(td)->planes; plane++) {
237 inframe.data[plane] = in->
data[plane];
238 inframe.linesize[plane] = in->
linesize[plane];
241 vsTransformPrepare(td, &inframe, &inframe);
244 for (plane = 0; plane < vsTransformGetDestFrameInfo(td)->planes; plane++) {
245 outframe.data[plane] = out->
data[plane];
246 outframe.linesize[plane] = out->
linesize[plane];
248 vsTransformPrepare(td, &inframe, &outframe);
251 vsDoTransform(td, vsGetNextTransform(td, &tc->
trans));
253 vsTransformFinish(td);
280 .
name =
"vidstabtransform",
282 "pass 2 of 2 for stabilization "
283 "(see vidstabdetect for pass 1)."),
289 .
inputs = avfilter_vf_vidstabtransform_inputs,
290 .
outputs = avfilter_vf_vidstabtransform_outputs,
291 .priv_class = &vidstabtransform_class,