I would like to add black stroke to text in ffmpeg. Is it possible?
-c:v libx264 -vf "hue=h=0, drawtext=fontfile=../bin/RobotoCondensed-Bold.ttf:text='Hello.':fontcolor=white: fontsize=158: x=0+(w-text_w)/2: y=50+(h-text_h-line_h)/2" -c:a copy -shortest -pix_fmt yuv420p ../bin/ENG_01.mov
You can change border-color and width of border by using drawtext and adding these parameters
bordercolor=black:
borderw=5:
Your code will look
-c:v libx264 \
-vf "hue=h=0,\
drawtext=fontfile=../bin/RobotoCondensed-Bold.ttf:\
text='Hello.':\
bordercolor=white:\
borderw=5:\
fontcolor=white:\
fontsize=158:\
x=0+(w-text_w)/2: y=50+(h-text_h-line_h)/2"\
-c:a copy -shortest -pix_fmt yuv420p \
../bin/ENG_01.mov
It's easier to use the subtitles filter instead of drawtext to add a full stroke.

ffmpeg will apply the Outline and OutlineColour options set in ASS files. Or you can manually set these in the ffmpeg command which is useful for other subtitle formats that don't support a stroke:
ffmpeg -i input -filter_complex "subtitles=your_subtitles_file.srt:force_style='Outline=5,OutlineColour=&H000000&'" output
From Advanced Substation Alpha Tags:
The color codes are given in hexadecimal in Blue Green Red order. Note that this is the opposite order of HTML color codes. Color codes must always start with
&Hand end with&. DefaultOutlineColouris black (&H000000&).

Use the borderw and bordercolor options:
ffmpeg -i input -filter_complex "drawtext=text='drawtext stroke':fontsize=36:fontcolor=white:borderw=4:bordercolor=black:x=(w-text_w)/2:y=(h-text_h)/2" output
bordercolor can accept hexadecimal values and you can also change the stroke opacity, such as with bordercolor=#[email protected].
See the drawtext filter documentation for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With