<p>The idea of having a box with text is to use the <a href="https://ffmpeg.org/ffmpeg-filters.html" rel="nofollow noreferrer">FFmpeg filter</a> i.e</p>
<pre><code>-vf &quot;drawtext=fontfile=Arial.ttf: text='%{frame_num}': start_number=1: x=(w-tw)/2: y=h-(2*lh): fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=5&quot;
</code></pre>
<p><a href="https://ffmpeg.org/ffmpeg-filters.html#drawtext-1" rel="nofollow noreferrer"><strong>drawtext</strong></a></p>
<ul>
<li><strong>fontfile</strong>: The font file to be used for drawing text. The path must be included. This parameter is mandatory if the fontconfig support is disabled.</li>
<li><strong>text</strong>: The text string to be drawn. The text must be a sequence of UTF-8 encoded characters. This parameter is mandatory if no file is specified with the parameter textfile.</li>
<li><strong>x,y</strong>: The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is &quot;0&quot;.</li>
<li><strong>fontcolor</strong>: The color to be used for drawing fonts. For the syntax of this option, check the (ffmpeg-utils)&quot;Color&quot; section in the ffmpeg-utils manual. The default value of fontcolor is &quot;black&quot;.</li>
<li><strong>fontsize</strong>: The font size to be used for drawing text. The default value of fontsize is 16.</li>
<li><strong>box</strong>: Used to draw a box around text using the background color. The value must be either 1 (enable) or 0 (disable). The default value of box is 0.</li>
<li><strong>boxcolor</strong>: The color to be used for drawing box around text. For the syntax of this option, check the (ffmpeg-utils)&quot;Color&quot; section in the ffmpeg-utils manual. The default value of boxcolor is &quot;white&quot;.</li>
<li><strong>boxborderw</strong>: Set the width of the border to be drawn around the text using bordercolor. The default value of borderw is 0</li>
</ul>

CC BY-SA 4.0
2021-12-13T07:45:55.480Z
Hi, thanks for your reply. I need  to do this subtitle effects with ffmpeg on subtitles.  


Example 1: https://www.facebook.com/watch/?v=498980114517638

Example 2: https://www.facebook.com/watch/?v=3985582161542560

How can i do it?
Doza De Adevar
CC BY-SA 4.0
2021-12-08T10:26:18.373Z
2021-12-08T10:26:18.373Z
xer-rex
<p>I need a script for ffmpeg to do this:</p>
<ol>
<li>Background color (drawbox) for all words like this:</li>
</ol>
<p><a href="https://i.sstatic.net/SNQSm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SNQSm.png" alt="enter image description here" /></a></p>

<ffmpeg><video><subtitles><script>
How can i do overlay subtitle with ffmpeg like in the links provided?
Doza De Adevar
# How can i do overlay subtitle with ffmpeg like in the links provided?

(Asked by: username_0 on 2021-11-29)

I need a script for ffmpeg to do this:

1. Background color (drawbox) for all words like this:

[![enter image description here](https://i.sstatic.net/SNQSm.png)](https://i.sstatic.net/SNQSm.png)

**Tags:** ffmpeg, video, subtitles, script


---

## 1 answers

### Answer by username_1 on 2021-12-08. Score: 0

The idea of having a box with text is to use the FFmpeg filter i.e
-vf "drawtext=fontfile=Arial.ttf: text='%{frame_num}': start_number=1: x=(w-tw)/2: y=h-(2*lh): fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=5"

drawtext

fontfile: The font file to be used for drawing text. The path must be included. This parameter is mandatory if the fontconfig support is disabled.
text: The text string to be drawn. The text must be a sequence of UTF-8 encoded characters. This parameter is mandatory if no file is specified with the parameter textfile.
x,y: The expressions which specify the offsets where text will be drawn within the video frame. They are relative to the top/left border of the output image. The default value of x and y is "0".
fontcolor: The color to be used for drawing fonts. For the syntax of this option, check the (ffmpeg-utils)"Color" section in the ffmpeg-utils manual. The default value of fontcolor is "black".
fontsize: The font size to be used for drawing text. The default value of fontsize is 16.
box: Used to draw a box around text using the background color. The value must be either 1 (enable) or 0 (disable). The default value of box is 0.
boxcolor: The color to be used for drawing box around text. For the syntax of this option, check the (ffmpeg-utils)"Color" section in the ffmpeg-utils manual. The default value of boxcolor is "white".
boxborderw: Set the width of the border to be drawn around the text using bordercolor. The default value of borderw is 0

> **Comments:**
> **username_0**: Hi, thanks for your reply. I need  to do this subtitle effects with ffmpeg on subtitles.     Example 1: https://www.facebook.com/watch/?v=498980114517638  Example 2: https://www.facebook.com/watch/?v=3985582161542560  How can i do it?  

---

