ffmpeg - horizontal align of multiple drawtext let you have a phrase where there is a word ( or a list of words ) that you want to underline, with a different color.

Apparently, you have to "split" your phrase into 3 different drawtext ( with different colors, but how can you set the exact "x" position for the second and third drawtext?

On the ffmpeg site , there is this example:

drawtext=fontfile=FreeSans.ttf:text=DOG:fontsize=24:x=10:y=20+24-max_glyph_a,
drawtext=fontfile=FreeSans.ttf:text=cow:fontsize=24:x=80:y=20+24-max_glyph_a


but I don't understand how to calculare the exact position of second element: "80" ? how "80" is calculated? 

And finally, is there another graceful option to draw a word inside a phrase with a different color? ( best would be to use a single drawtext )
Make ASS (Advanced SubStation Alpha) subtitles and use the subtitles filter:



ffmpeg -i video.mp4 -filter_complex "subtitles=your_subtitles.ass" -c:a copy output.mp4



You can make the subtitles manually or with Aegisub.
SRT (Subrip) subtitles are much simpler than ASS and would be easier to make manually, but they will lack features that ASS can support. SRT will suffice for simple styling however (underline, bold, italics, etc), but not individual per-word color changing as far as I know.