Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include font in FFMPEG command without using the fontfile option?

Tags:

ffmpeg

I am using the following command to add watermark in my video using font TIMESNEWROMAN:

ffmpeg -i input.webm -vf "drawtext=text='© Krishna':fontfile=C//:/Windows/Fonts/times.ttf:x=(main_w-text_w-10):y=(main_h-text_h-10):fontsize=32:fontcolor=black:box=1:[email protected]: boxborderw=5" -preset ultrafast output.mp4

Now, I want to provide the font TIMESNEWROMAN or any other font instead of fontfile path. Is it possible to do that?

like image 215
Avinash Modi Avatar asked Oct 16 '25 18:10

Avinash Modi


1 Answers

Use the font option

If your ffmpeg was compiled with --enable-libfontconfig you can use the font option. From the drawtext filter documentation:

font
The font family to be used for drawing text. By default Sans.

Example

ffmpeg -i input.webm -vf "drawtext=text='© Krishna':font='Times New Roman':x=(main_w-text_w-10):y=(main_h-text_h-10):fontsize=32:fontcolor=black:box=1:[email protected]:boxborderw=5" output.mp4

To check for libfontconfig support

To check if your ffmpeg has --enable-libfontconfig just run the ffmpeg command with no options and it will output the configuration. Then look for --enable-libfontconfig.

If you don't have libfontconfig

  • Windows users can download ffmpeg from BtbN which includes libfontconfig support.
  • macOS users can download ffmpeg from evermeet.cx or use Homebrew with the --with-fontconfig option.
  • Linux users can compile.
like image 187
llogan Avatar answered Oct 19 '25 14:10

llogan