[FFmpeg-devel] vf_drawtext: add force_boxw_equl_textw option
su.gao
sugao_cn at 163.com
Tue Feb 14 09:02:46 EET 2017
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];
+ }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg_drawtext_force_boxw_equl_textw.patch
Type: application/octet-stream
Size: 2132 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170214/060da7de/attachment.obj>
More information about the ffmpeg-devel
mailing list