[FFmpeg-devel] [PATCH] vf_drawtext: make x and y options parametric

Stefano Sabatini stefasab at gmail.com
Thu Sep 22 01:14:12 CEST 2011


On date Wednesday 2011-09-21 22:14:26 +0200, Víctor Paesa encoded:
> Hi,
> 
> 2011/9/21 Víctor Paesa :
> > Hi
> >
> > On Wed, Sep 21, 2011 at 10:33, Stefano Sabatini wrote:
> >> On date Tuesday 2011-09-20 23:49:18 +0200, Víctor Paesa encoded:
[...]
> >>> It would be nice to expose too either the ascent or the descent
> >>> (y_max or y_min in code).
> >>
> >> Please can you suggest an application for this? So I can add an
> >> illustrative example in the docs.
> >
> > The height of 'g' is the same of 'd', but one goes over the baseline,
> > and the other goes down it.
> > If you draw words splitted in several commands, you want to make all
> > of them follow a common baseline.
> >
> > For example:
> > Properly show "good" with initial "g" in different color at the center
> > of the video frame:
> >
> > drawtext=fontsize=30:fontfile=FreeSerif.ttf:fontcolor=green:text='g':x=(w-text_w)/2:y=(h-text_h+ascent-line_h)/2
> > drawtext=fontsize=30:fontfile=FreeSerif.ttf:fontcolor=red:text='ood':x=(w-text_w)/2:y=(h-text_h+ascent-line_h)/2
> >
> > Improperly show "not good" with initial "not g" in different color at
> > the center of the video frame:
> >
> > drawtext=fontsize=30:fontfile=FreeSerif.ttf:fontcolor=green:text='not
> > g':x=(w-text_w)/2:y=(h-text_h-line_h)/2
> > drawtext=fontsize=30:fontfile=FreeSerif.ttf:fontcolor=red:text='ood':x=(w-text_w)/2:y=(h-text_h-line_h)/2
> 
> Hmm, poor example, because the two text fragments are
> drawn one of top of the other.
> It would be nice if the text_w of the first fragment could be
> used to draw the second, but that is not possible.
> 
> So the example (ruining parametric horizontal centering) is:
> drawtext=fontsize=30:fontfile=FreeSerif.ttf:fontcolor=green:text='g':x=w/2:y=(h-text_h+ascent-line_h)/2
> drawtext=fontsize=30:fontfile=FreeSerif.ttf:fontcolor=red:text='ood':x=w/2+22:y=(h-text_h+ascent-line_h)/2

Updated work in progress, not still ready for commit with a few fixes
and the addition of the ascent/descent/max_glyph_w constants.

Still missing:

* documentation for the new variables (in particular about the meaning
  of ascent/descent)

* better names or short aliases for max_glyph_h/w (suggestions are
  welcome...), also max_glyph_h == line_h so maybe I should keep an
  alias for that

* figure out how to deal with the wrapline feature, I don't think it
  is possible to conciliate it easily with moving x/y, but I see it is
  useful under certain scenarios so I'd like to keep it at least as a
  tweakable option.
-- 
FFmpeg = Furious Freak Merciless Prodigious Empowered Gadget
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-vf_drawtext-make-x-and-y-options-parametric.patch
Type: text/x-diff
Size: 15779 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110922/a5a9b639/attachment.bin>


More information about the ffmpeg-devel mailing list