You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<codeclass="descclassname">ffmpeg.</code><codeclass="descname">drawtext</code><spanclass="sig-paren">(</span><em>stream</em>, <em>text=None</em>, <em>x=0</em>, <em>y=0</em>, <em>escape_text=True</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#ffmpeg.drawtext" title="Permalink to this definition">¶</a></dt>
147
+
<dd><p>Draw a text string or text from a specified file on top of a video, using the libfreetype library.</p>
148
+
<p>To enable compilation of this filter, you need to configure FFmpeg with <codeclass="docutils literal"><spanclass="pre">--enable-libfreetype</span></code>. To enable default
149
+
font fallback and the font option you need to configure FFmpeg with <codeclass="docutils literal"><spanclass="pre">--enable-libfontconfig</span></code>. To enable the
150
+
text_shaping option, you need to configure FFmpeg with <codeclass="docutils literal"><spanclass="pre">--enable-libfribidi</span></code>.</p>
<p>Default value is “default”. For more information consult the documentation for the FT_LOAD_* libfreetype
207
+
flags.</p>
208
+
</li>
209
+
<li><strong>shadowcolor</strong> – The color to be used for drawing a shadow behind the drawn text. For the syntax of this option,
210
+
check the “Color” section in the ffmpeg-utils manual. The default value of shadowcolor is “black”.</li>
211
+
<li><strong>shadowx</strong> – The x offset for the text shadow position with respect to the position of the text. It can be either
212
+
positive or negative values. The default value is “0”.</li>
213
+
<li><strong>shadowy</strong> – The y offset for the text shadow position with respect to the position of the text. It can be either
214
+
positive or negative values. The default value is “0”.</li>
215
+
<li><strong>start_number</strong> – The starting frame number for the n/frame_num variable. The default value is “0”.</li>
216
+
<li><strong>tabsize</strong> – The size in number of spaces to use for rendering the tab. Default value is 4.</li>
217
+
<li><strong>timecode</strong> – Set the initial timecode representation in “hh:mm:ss[:;.]ff” format. It can be used with or without
218
+
text parameter. timecode_rate option must be specified.</li>
219
+
<li><strong>rate</strong> – Set the timecode frame rate (timecode only).</li>
220
+
<li><strong>timecode_rate</strong> – Alias for <codeclass="docutils literal"><spanclass="pre">rate</span></code>.</li>
221
+
<li><strong>r</strong> – Alias for <codeclass="docutils literal"><spanclass="pre">rate</span></code>.</li>
222
+
<li><strong>tc24hmax</strong> – If set to 1, the output of the timecode option will wrap around at 24 hours. Default is 0 (disabled).</li>
223
+
<li><strong>text</strong> – The text string to be drawn. The text must be a sequence of UTF-8 encoded characters. This parameter is
224
+
mandatory if no file is specified with the parameter textfile.</li>
225
+
<li><strong>textfile</strong> – A text file containing text to be drawn. The text must be a sequence of UTF-8 encoded characters.
226
+
This parameter is mandatory if no text string is specified with the parameter text. If both text and
227
+
textfile are specified, an error is thrown.</li>
228
+
<li><strong>reload</strong> – If set to 1, the textfile will be reloaded before each frame. Be sure to update it atomically, or it
229
+
may be read partially, or even fail.</li>
230
+
<li><strong>x</strong> – The expression which specifies the offset where text will be drawn within the video frame. It is relative to
231
+
the left border of the output image. The default value is “0”.</li>
232
+
<li><strong>y</strong> – The expression which specifies the offset where text will be drawn within the video frame. It is relative to
233
+
the top border of the output image. The default value is “0”. See below for the list of accepted constants
234
+
and functions.</li>
235
+
</ul>
236
+
</td>
237
+
</tr>
238
+
</tbody>
239
+
</table>
240
+
<dlclass="docutils">
241
+
<dt>Expression constants:</dt>
242
+
<dd><dlclass="first docutils">
243
+
<dt>The parameters for x and y are expressions containing the following constants and functions:</dt>
244
+
<dd><ulclass="first last simple">
245
+
<li>dar: input display aspect ratio, it is the same as <codeclass="docutils literal"><spanclass="pre">(w</span><spanclass="pre">/</span><spanclass="pre">h)</span><spanclass="pre">*</span><spanclass="pre">sar</span></code></li>
246
+
<li>hsub: horizontal chroma subsample values. For example for the pixel format “yuv422p” hsub is 2 and vsub
247
+
is 1.</li>
248
+
<li>vsub: vertical chroma subsample values. For example for the pixel format “yuv422p” hsub is 2 and vsub
249
+
is 1.</li>
250
+
<li>line_h: the height of each text line</li>
251
+
<li>lh: Alias for <codeclass="docutils literal"><spanclass="pre">line_h</span></code>.</li>
252
+
<li>main_h: the input height</li>
253
+
<li>h: Alias for <codeclass="docutils literal"><spanclass="pre">main_h</span></code>.</li>
254
+
<li>H: Alias for <codeclass="docutils literal"><spanclass="pre">main_h</span></code>.</li>
255
+
<li>main_w: the input width</li>
256
+
<li>w: Alias for <codeclass="docutils literal"><spanclass="pre">main_w</span></code>.</li>
257
+
<li>W: Alias for <codeclass="docutils literal"><spanclass="pre">main_w</span></code>.</li>
258
+
<li>ascent: the maximum distance from the baseline to the highest/upper grid coordinate used to place a glyph
259
+
outline point, for all the rendered glyphs. It is a positive value, due to the grid’s orientation with the Y
260
+
axis upwards.</li>
261
+
<li>max_glyph_a: Alias for <codeclass="docutils literal"><spanclass="pre">ascent</span></code>.</li>
262
+
<li>descent: the maximum distance from the baseline to the lowest grid coordinate used to place a glyph outline
263
+
point, for all the rendered glyphs. This is a negative value, due to the grid’s orientation, with the Y axis
264
+
upwards.</li>
265
+
<li>max_glyph_d: Alias for <codeclass="docutils literal"><spanclass="pre">descent</span></code>.</li>
266
+
<li>max_glyph_h: maximum glyph height, that is the maximum height for all the glyphs contained in the rendered
267
+
text, it is equivalent to ascent - descent.</li>
268
+
<li>max_glyph_w: maximum glyph width, that is the maximum width for all the glyphs contained in the rendered
269
+
text.</li>
270
+
<li>n: the number of input frame, starting from 0</li>
271
+
<li>rand(min, max): return a random number included between min and max</li>
272
+
<li>sar: The input sample aspect ratio.</li>
273
+
<li>t: timestamp expressed in seconds, NAN if the input timestamp is unknown</li>
274
+
<li>text_h: the height of the rendered text</li>
275
+
<li>th: Alias for <codeclass="docutils literal"><spanclass="pre">text_h</span></code>.</li>
276
+
<li>text_w: the width of the rendered text</li>
277
+
<li>tw: Alias for <codeclass="docutils literal"><spanclass="pre">text_w</span></code>.</li>
278
+
<li>x: the x offset coordinates where the text is drawn.</li>
279
+
<li>y: the y offset coordinates where the text is drawn.</li>
280
+
</ul>
281
+
</dd>
282
+
</dl>
283
+
<pclass="last">These parameters allow the x and y expressions to refer each other, so you can for example specify
<codeclass="descclassname">ffmpeg.</code><codeclass="descname">filter_</code><spanclass="sig-paren">(</span><em>stream_spec</em>, <em>filter_name</em>, <em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#ffmpeg.filter_" title="Permalink to this definition">¶</a></dt>
0 commit comments