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

Viewed 2677

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:boxcolor=white@0.5: 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?

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:boxcolor=white@0.5: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

Related