<p>Make ASS (Advanced SubStation Alpha) subtitles and use the <a href="https://ffmpeg.org/ffmpeg-filters.html#subtitles-1" rel="nofollow noreferrer">subtitles filter</a>:</p>

<p><a href="https://i.sstatic.net/TC28w.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TC28w.png" alt="enter image description here"></a></p>

<pre><code>ffmpeg -i video.mp4 -filter_complex "subtitles=your_subtitles.ass" -c:a copy output.mp4
</code></pre>

<ul>
<li>You can make the subtitles manually or with <a href="http://aegisub.org/" rel="nofollow noreferrer">Aegisub</a>.</li>
<li>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.</li>
</ul>

CC BY-SA 3.0
2018-03-08T17:59:49.320Z
2018-03-08T18:04:57.123Z
2018-03-08T18:04:57.123Z
llogan
<p>let you have a phrase where there is a word ( or a list of words ) that you want to underline, with a different color.</p>

<p>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?</p>

<p>On the ffmpeg site , there is this example:</p>

<pre><code>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
</code></pre>

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

<p>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 )</p>

<ffmpeg>
ffmpeg - horizontal align of multiple drawtext
GFCoder977
# ffmpeg - horizontal align of multiple drawtext

(Asked by: username_0 on 2018-03-08)

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 )

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2018-03-08. Score: 1

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.


---

