Hi, I am working on a programming project with ffmpeg.
At the projects current junction, I am trying to write text onto image sequences (or video for that matter). But ffmpeg will not draw any text at all for some reason and I can't seem to figure out why other than trying to read its cryptic error message "[AVFilterGraph @ 003dcf80] Error initializing filter 'drawtext'". So I thought that I would try and go as basic as I can and shorten my purpose to just drawing text only, no boxes, transparency, timecode, or anything. Maybe that will help, but it didn't. And i'm stuck in a rut and turning here for some help if possible.
Here is the full error message from ffmpeg's output, including the parameter line being used:
The test script above is suppose to write "my_video" onto the video but fails.Code:ffmpeg -i "video.mkv" -an -vf drawtext=text="my_video" -r 0.30 "%d.jpg" ffmpeg version N-82143-gbf14393 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib libavutil 55. 35.100 / 55. 35.100 libavcodec 57. 65.100 / 57. 65.100 libavformat 57. 57.100 / 57. 57.100 libavdevice 57. 2.100 / 57. 2.100 libavfilter 6. 66.100 / 6. 66.100 libswscale 4. 3.100 / 4. 3.100 libswresample 2. 4.100 / 2. 4.100 libpostproc 54. 2.100 / 54. 2.100 [hevc @ 00388120] Stream #0: not enough frames to estimate rate; consider increasing probesize Input #0, hevc, from 'video.mkv': Duration: N/A, bitrate: N/A Stream #0:0: Video: hevc (Main), yuv420p(tv), 720x480, 23.98 fps, 23.98 tbr, 1200k tbn, 23.98 tbc [Parsed_drawtext_0 @ 059567c0] Either text, a valid file or a timecode must be provided [AVFilterGraph @ 0038fd00] Error initializing filter 'drawtext' Error opening filters!
I've read the following link and tried all the examples, but they all fail: http://ffmpeg.org/ffmpeg-filters.html#Examples-47
My goals (once I get this working) are several: write the filename onto the video; set transparency to the text; write a timecode on the image; write a frame number; create a contactsheet; and other ideas. I know I can do most of these functions in avisynth, but that is not something I need to do in every video project. I need an non-avisynth aproach, hence an ffmpeg approach.
Thank you in advance for any helpful answers.
+ Reply to Thread
Results 1 to 22 of 22
-
-
Works for me:
Code:drawtext='fontsize=64:fontcolor=white@0.8:box=1:boxcolor=black@0.75:boxborderw=16:fontfile=OCRA.ttf:text='my_video':x=(w-tw)/2:y=th'
Last edited by pandy; 5th Feb 2017 at 14:22.
-
still won't work. same error message.
[AVFilterGraph @ 05a4fa60] Error initializing filter 'drawtext' with args 'fontsize=64:fontcolor=white@0.8:box=1:boxcolor=bl ack@0.75:boxborderw=16:fontfile=OCRA.ttf:text=my_v ideo:x=(w-tw)/2:y=th'
edit: It doesn't like the colon ":" for the function separater, rather it expects the comma "," instead. But its still not working.
I am running under windows 7 home prem 64bit (tried 32/64bit ffmpeg, same results) -
Code:
@ffplay -loop 0 -i "%1" -vf drawtext='fontsize=64:fontcolor=white@0.8:box=1:boxcolor=black@0.75:boxborderw=16:fontfile=OCRA.ttf:text='my_video':x=(w-tw)/2:y=th'
-
works for me too
99.9% of the time it's a font error for ffmpeg or mencoder. You need to specify the path of the font ,or it has to be in the search path. Start with something simple
In this example, if "FreeSerif.ttf" wasn't in the path (for example in the same directory), you'd need to specify exactly where it is located.
Code:-vf drawtext="fontfile=FreeSerif.ttf:text='Test'"
-
Just download a free font file. I'll upload one here. It doesn't have to be installed. Just unzip the font that you want, and specify the directory that you put it in in the commandline (or if you put it in the same directory you don't have to specify a path)
-
Well, ffmpeg issue woith fonts under windows is common, i sue something like:
as a part of each batch some startup sequence:
Code:@set FC_CONFIG_DIR=%FFMPG%\conf @set FONTCONFIG_FILE=%FFMPG%\conf\fonts.conf @set FONTCONFIG_PATH=%FFMPG%\conf
and inside this folder there is config file "fonts.conf" like:
Code:<?xml version="1.0"?> <fontconfig> <dir>C:\WINDOWS\Fonts</dir> <match target="pattern"> <test qual="any" name="family"><string>mono</string></test> <edit name="family" mode="assign"><string>monospace</string></edit> </match> <match target="pattern"> <test qual="all" name="family" compare="not_eq"><string>sans-serif</string></test> <test qual="all" name="family" compare="not_eq"><string>serif</string></test> <test qual="all" name="family" compare="not_eq"><string>monospace</string></test> <edit name="family" mode="append_last"><string>sans-serif</string></edit> </match> <alias> <family>Times</family> <prefer><family>Times New Roman</family></prefer> <default><family>serif</family></default> </alias> <alias> <family>Helvetica</family> <prefer><family>Arial</family></prefer> <default><family>sans</family></default> </alias> <alias> <family>Courier</family> <prefer><family>Courier New</family></prefer> <default><family>monospace</family></default> </alias> <alias> <family>serif</family> <prefer><family>Times New Roman</family></prefer> </alias> <alias> <family>sans</family> <prefer><family>Arial</family></prefer> </alias> <alias> <family>monospace</family> <prefer><family>Andale Mono</family></prefer> </alias> <match target="pattern"> <test name="family" compare="eq"> <string>Courier New</string> </test> <edit name="family" mode="prepend"> <string>monospace</string> </edit> </match> <match target="pattern"> <test name="family" compare="eq"> <string>Courier</string> </test> <edit name="family" mode="prepend"> <string>monospace</string> </edit> </match> </fontconfig>
It work somehow... -
Well, i copied the "FreeSerif.ttf" file into my ffmpeg folder, but it still will not work. I even explicitly gave it a path name and it still won't work.
Code:Input #0, matroska,webm, from 'video.mkv': Metadata: ENCODER : Lavf57.48.101 Duration: 00:00:42.90, start: 0.000000, bitrate: 2474 kb/s Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1k fps, 50 tbr, 1k tbn, 100 tbc (default) Metadata: DURATION : 00:00:42.900000000 Fontconfig error: Cannot load default config file [Parsed_drawtext_0 @ 0000000002f6f7c0] Cannot find a valid font for the family Sans [AVFilterGraph @ 00000000030f7180] Error initializing filter 'drawtext' with args 'fontfile=FreeSerif.ttf:text=test' Error opening filters!
-
Try again with double quotes around the whole filter string, and single quotes around your text:
Code:-vf "fontsize=64:fontcolor=white@0.8:box=1:boxcolor=black@0.75:boxborderw=16:fontfile=OCRA.ttf:text='my_video':x=(w-tw)/2:y=th"
Code:-vf "fontsize=64:fontcolor=white@0.8:box=1:boxcolor=black@0.75:boxborderw=16:fontfile=OCRA.ttf:x=(w-tw)/2:y=th:text=my video"
Me too. I had to place my font file in the current working directory. -
On windows, for ffmpeg drawtext, if you specify a path, you need to escape properly with a backslash . For every colon, you need to precede with a "\" , and for every "\" such as in a directory path, you need to add another "\". It's really computer geeky programming stuff and I don't know all the proper jargon. And I though this was bad ... but vapoursynth is 10x worse. It's very strict geeky programming. It's even case sensitive. People with programming background are fine, but "normal" people like me scratch their heads... It's sometime easier to just place the .ttf file in the video directory
anyways...
e.g. if I had FreeSerif.ttf in my "F:\_DOWNLOADS" directory
I put in RED the added characters from a "normal" windows directory path
Code:-vf drawtext="fontfile='F\:\\_DOWNLOADS\\FreeSerif.ttf':text='TEST'"
Last edited by poisondeathray; 5th Feb 2017 at 15:56.
-
still not working. tried every combination of all suggestions.
I have to assume now, that the error must be related to a missing install from ffmpeg, of which no longer comes with ffmpeg. the 'config' folder. remember that?
I have downloaded many ffmpeg builds, since probably around 2014 and can't find a single reference to a folder for 'config' let alone, for 'font' from those archives.
So i must resign with the following un-resolvable fault:
Fontconfig error: Cannot load default config file -
no. i downloaded it from here: https://www.videohelp.com/software/ffmpeg -- (32 and 64 bit portable versions)
-
Fontconfig error: Cannot load default config file
I get the same, but not if I supply a font file.
Your ffmpeg banner should include the following:Code:--enable-fontconfig --enable-libfreetype
-
download a build from zeranoe, they have fontconfig enabled . They definitely work on windows with drawtext for at least 2 years. Prior to that there were various issues globally with ffmpeg and fonts (same with mencoder)
https://ffmpeg.zeranoe.com/builds/
all windows since Win95 (?) come with Arial.ttf in the C:\Windows\Fonts\ directory . Yeah it's a "blah" font but whatever just testing here
Try this (I'm assuming you have standard windows installed on C:\ drive)
Code:ffmpeg -f lavfi -r 24 -i color=c=white:s=640x480 -vf drawtext="fontsize=40:fontfile='C\:\\Windows\\Fonts\\Arial.ttf':text='TEST'" -c:v libx264 -crf 20 -an -frames:v 120 test.mp4
-
success.
@ raff, they are enabled in the builds i've been using, including the latest two I just downloaded today.
@ pois, your method works! that is, with the revised usage of the '\\' chars. I'da never figured out 'c\'. oh, and your font (post #7) worked as well. thanks!
Code:-vf drawtext="fontsize=40:fontfile='C\:\\Windows\\Fonts\\Arial.ttf':text='TEST'"
And now to figure out how to replace 'test' with variables like current-frame and timecode, etc.Last edited by vhelp; 5th Feb 2017 at 17:30.
-
There are examples posted on the documentation page
https://ffmpeg.org/ffmpeg-filters.html#drawtext-1
current frame is %{n}
timecode can be represented by pts (presentation time stamps). If you wanted it hh:mins.ms standard format, you would specify hms (remembering the windows escaping, because you're using a colon)
eg.
Code:ffmpeg -f lavfi -r 24 -i color=c=white:s=640x480 -vf drawtext="fontsize=20:fontfile='C\:\\Windows\\Fonts\\Arial.ttf':text='FrameNumber_%{n} , TC_%{pts\:hms}'" -c:v libx264 -crf 20 -an -frames:v 120 test.mp4
-
thanks. i think i got it now. but the examples in that documentation can be tricky to get working. i had tried with the timestamp, finally got it working. anyway, thanks for your help, appreciated. i'm pooped, been at this since 1032am.
Similar Threads
-
Ffmpeg with http proxy not working
By Karol in forum Video Streaming DownloadingReplies: 2Last Post: 23rd Nov 2016, 09:22 -
MKV to MP4 video not working after FFMPEG copy
By contraplex in forum Video ConversionReplies: 3Last Post: 26th Jul 2015, 06:40 -
ffmpeg.exe has stoped working
By downer in forum SVCD2DVD & VOB2MPGReplies: 33Last Post: 6th Aug 2014, 16:45 -
FFMPEG - Adding Audio to Video Not Working Correctly
By Endemoniada in forum Video ConversionReplies: 3Last Post: 31st Jan 2013, 06:18 -
AVSTODVD ffmpeg stopped working
By stem300 in forum Video ConversionReplies: 4Last Post: 30th May 2012, 05:47