FFmpeg drawtext - Could not load fontface from file
Solution 1
You cannot have a colon in the path to your font file as the colon acts as a key sepperator in ffmpeg. I had the same problem.
try:
ffmpeg -i C:\Test\rec\vid_1321909320.avi -vf drawtext=fontfile=/Windows/Fonts/arial.ttf:text=test -sameq vid_1321909320.flv
Solution 2
A colon ":" and a backslash "\" have special meaning when specifying the parameters for drawtext. So what you can do is to escape them by converting ":" to "\:" and "\" to "\\". Also you can enclose the path to your font file in single quotes incase the path contains spaces.
So you will have
ffmpeg -i C:\Test\rec\vid_1321909320.avi -vf drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf':text=test vid_1321909320.flv
Solution 3
I was also having trouble with ffmpeg recognizing Windows paths. I finally just put the font Arial.ttf in the same folder as the input file and it worked.
[drawtext @ 03C66EA0] Key '/Windows/Fonts/Arial.ttf: text' not found.
[drawtext @ 03C66E00] Error parsing options string: 'fontfile=C:/Windows/Fonts/Arial.ttf: text=Test Text:x=100: y=50: fontsize=24: [email protected]: box=1: [email protected]'
Error initializing filter 'drawtext' with args 'fontfile=C:/Windows/Fonts/Arial.ttf: text=Test Text:x=100: y=50: fontsize=24: [email protected]: box=1: [email protected]'
Error opening filters!
Comments
-
falek.marcin almost 2 years
I've try to add simple text on top of video with FFmpeg using drawtext parameter. Every time i'm going to do this, error is returned:
Could not load fontface from file 'arial.ttf': cannot open resource
To indicate the location of the font I used the following methods:
ffmpeg -i C:\Test\rec\vid_1321909320.avi -vf drawtext=fontfile=arial.ttf:text=test -sameq vid_1321909320.flv ffmpeg -i C:\Test\rec\vid_1321909320.avi -vf drawtext=fontfile=C:\Windows\Fonts\arial.ttf:text=test -sameq vid_1321909320.flv
All have failed. Does anyone have experience with adding text using ffmpeg?
FFMPEG version: N-34549-g13b7781 build on Nov 6 2011
-
falek.marcin over 12 yearsYour solution also works. Thanks
-
Jaex about 10 yearsAnswer from 2011 was not working but adentum's answer worked.
-
DrHaze over 9 yearsStill usefull in 2015.
-
MarianD over 7 yearsStill usefull in 2017
-
adentum about 7 years:D So I am an archaeologist :)
-
Brad almost 7 yearsStill useful in 2018!
-
7vujy0f0hy over 5 yearsWorks for me in 2019.
-
7vujy0f0hy over 5 years@adentum: The age of your reply (6 years) is now greater than the age of the question at the time your reply (1 year). What do you call a fossilised archaeologist?
-
Rick over 5 yearsDid not work with me, this did: stackoverflow.com/a/47432274/920323
-
Owen M almost 5 yearsYou are a savior
-
Chris Woods over 4 yearsUsing forward slashes is the appropriate way to reference a font file, even on Windows. To do this properly, I escaped the colon and use forward slashes, and enclosed it in single quotes, e.g.
fontfile='C\:/WINDOWS/fonts/lucon.ttf'
-
Chris Woods over 4 yearsUsing forward slashes is the appropriate way to reference a font file, including on Windows. To do this on my Win10 machine, I escaped the colon, used forward slashes and enclosed the path in single quotes, e.g.
fontfile='C\:/WINDOWS/fonts/lucon.ttf'
-
sigur7 about 4 yearsWindows 10 fix: Copy font from C:\Windows\Fonts\Lato\Lato-Bold.ttf to the same folder as where the input file is located. Then just reference it like so
drawtext=fontfile=Lato-Bold.ttf