[FFmpeg-devel] vf_drawtext: add force_boxw_equl_textw option

Steven Liu lingjiujianke at gmail.com
Tue Feb 14 09:25:35 EET 2017


2017-02-14 15:02 GMT+08:00 su.gao <sugao_cn at 163.com>:

> Add this option to force the  box width equl text width:
>
> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> index 0b94725..5b16cfa 100644
> --- a/libavfilter/vf_drawtext.c
> +++ b/libavfilter/vf_drawtext.c
> @@ -164,6 +164,7 @@ typedef struct DrawTextContext {
>      int use_kerning;                ///< font kerning is used - true/false
>      int tabsize;                    ///< tab size
>      int fix_bounds;                 ///< do we let it go out of frame
> bounds - t/f
> +    int force_boxw_equl_textw;                    ///< tab size
>
>      FFDrawContext dc;
>      FFDrawColor fontcolor;          ///< foreground color
> @@ -209,6 +210,7 @@ static const AVOption drawtext_options[]= {
>      {"bordercolor", "set border color",     OFFSET(bordercolor.rgba),
>  AV_OPT_TYPE_COLOR,  {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS},
>      {"shadowcolor", "set shadow color",     OFFSET(shadowcolor.rgba),
>  AV_OPT_TYPE_COLOR,  {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS},
>      {"box",         "set box",              OFFSET(draw_box),
>  AV_OPT_TYPE_BOOL,   {.i64=0},     0,        1       , FLAGS},
> +    {"force_boxw_equl_textw",       "force the  box width equl text
> width",     OFFSET(force_boxw_equl_textw),           AV_OPT_TYPE_BOOL,
>  {.i64=0},     0,        1       , FLAGS},
>      {"boxborderw",  "set box border width", OFFSET(boxborderw),
>  AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX , FLAGS},
>      {"line_spacing",  "set line spacing in pixels",
> OFFSET(line_spacing),   AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,
> INT_MAX,FLAGS},
>      {"fontsize",    "set font size",        OFFSET(fontsize),
>  AV_OPT_TYPE_INT,    {.i64=0},     0,        INT_MAX , FLAGS},
> @@ -1298,7 +1300,11 @@ static int draw_text(AVFilterContext *ctx, AVFrame
> *frame,
>      update_color_with_alpha(s, &bordercolor, s->bordercolor);
>      update_color_with_alpha(s, &boxcolor   , s->boxcolor   );
>
> -    box_w = FFMIN(width - 1 , max_text_line_w);
> +    if(0==s->force_boxw_equl_textw){
> +        box_w = FFMIN(width - 1 , max_text_line_w);
> +    }else{
> +        box_w =   (int)s->var_values[VAR_TEXT_W];
> +    }
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
don't use git diff make patch please,
You can use git commit and git format-patch make patch and use git
send-email send patch to maillist.

please refer to : https://ffmpeg.org/developer.html#toc-Submitting-patches-1


More information about the ffmpeg-devel mailing list