Browse code

added start_number parameter to drawtext to permit an offset to n/frame_num var

Mark Visser authored on 2013/05/22 05:14:46
Showing 2 changed files
... ...
@@ -3068,6 +3068,10 @@ The x and y offsets for the text shadow position with respect to the
3068 3068
 position of the text. They can be either positive or negative
3069 3069
 values. Default value for both is "0".
3070 3070
 
3071
+@item start_number
3072
+The starting frame number for the n/frame_num variable. The default value
3073
+is "0".
3074
+
3071 3075
 @item tabsize
3072 3076
 The size in number of spaces to use for rendering the tab.
3073 3077
 Default value is 4.
... ...
@@ -164,6 +164,7 @@ typedef struct {
164 164
     AVTimecode  tc;                 ///< timecode context
165 165
     int tc24hmax;                   ///< 1 if timecode is wrapped to 24 hours, 0 otherwise
166 166
     int reload;                     ///< reload text file for each frame
167
+    int start_number;               ///< starting frame number for n/frame_num var
167 168
 } DrawTextContext;
168 169
 
169 170
 #define OFFSET(x) offsetof(DrawTextContext, x)
... ...
@@ -198,6 +199,7 @@ static const AVOption drawtext_options[]= {
198 198
     {"rate",            "set rate (timecode only)",         OFFSET(tc_rate),       AV_OPT_TYPE_RATIONAL, {.dbl=0},           0,  INT_MAX, FLAGS},
199 199
     {"reload",     "reload text file for each frame",                       OFFSET(reload),     AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS},
200 200
     {"fix_bounds", "if true, check and fix text coords to avoid clipping",  OFFSET(fix_bounds), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS},
201
+    {"start_number", "start frame number for n/frame_num variable", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
201 202
 
202 203
     /* FT_LOAD_* flags */
203 204
     { "ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), AV_OPT_TYPE_FLAGS, { .i64 = FT_LOAD_DEFAULT | FT_LOAD_RENDER}, 0, INT_MAX, FLAGS, "ft_load_flags" },
... ...
@@ -614,7 +616,7 @@ static int func_frame_num(AVFilterContext *ctx, AVBPrint *bp,
614 614
 {
615 615
     DrawTextContext *s = ctx->priv;
616 616
 
617
-    av_bprintf(bp, "%d", (int)s->var_values[VAR_N]);
617
+    av_bprintf(bp, "%d", (int)s->var_values[VAR_N]+s->start_number);
618 618
     return 0;
619 619
 }
620 620