New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fontconfig error: Cannot load default config file #18

Closed
dominicthomas opened this Issue Aug 21, 2015 · 9 comments

Comments

Projects
None yet
5 participants
@dominicthomas

dominicthomas commented Aug 21, 2015

I am using one of the prebuilt binaries in my project and am trying to draw text over a video file.

I am executing the process using a complex command in the form of a String[] instead of converting an ArrayList to a one command string. I had to do this to allow for the use of complex filters as having single or double quotes in a single string command doesn't work.

The binaries compiled claim to include libfreetype and libfribidi. The documentation for drawtext (http://ffmpeg.org/ffmpeg-filters.html#drawtext-1) says that libfontconfig also needs to be included to enable the font feature and the default font fallback feature.

This seems like a catch 22 as if you don't want include a font, ffmpeg has no way of falling back to a default.

Can you let me know if libfontconfig should be included and if not, would it be possible to make a prebuilt binary with it enabled? (I'd do it myself but am having trouble compiling)

Here is the complex command I am running:
final String[] complexCommand = {mFfmpegBin, "-i", inClip.path, "-vf", "drawtext=enable='between(t, 0, 3)':fontfile" + fontPath + ":text='Text to write is this, overlaid':fontsize=20:fontcolor=red:x=100:y=100", "-y", mediaOut.path};

Here is the shell output:
I/System.out﹕[Parsed_drawtext_0 @ 0xb5864420] Could not load font "(null)": invalid argument
I/System.out﹕ Fontconfig error: Cannot load default config file
I/System.out﹕ [Parsed_drawtext_0 @ 0xb5864420] Cannot find a valid font for the family Sans
I/System.out﹕ [AVFilterGraph @ 0xb5868080] Error initializing filter 'drawtext' with args 'enable=between(t, 0, 3):text=Text to write is this, overlaid:fontsize=20:fontcolor=red:x=100:y=100'
I/System.out﹕ Error opening filters!

Thanks

@hiteshsondhi88

This comment has been minimized.

Show comment
Hide comment
@hiteshsondhi88

hiteshsondhi88 Aug 21, 2015

Member

@dominicthomas do check the instructions

Member

hiteshsondhi88 commented Aug 21, 2015

@dominicthomas do check the instructions

@dominicthomas

This comment has been minimized.

Show comment
Hide comment
@dominicthomas

dominicthomas Aug 21, 2015

@hiteshsondhi88 Thanks for responding. Since posting the question I've double checking what is included in the ffmpeg_build.sh. I can see that all the required font libraries are enabled. However it is unclear to me how to follow the instructions relating to fontconfig.

Just to confirm, Is the instruction to set an environment variable before compilation, with a path of a yet to exist fonts.conf file, decided in advance? Any clues on what should be in the fonts.conf file?

Many thanks

dominicthomas commented Aug 21, 2015

@hiteshsondhi88 Thanks for responding. Since posting the question I've double checking what is included in the ffmpeg_build.sh. I can see that all the required font libraries are enabled. However it is unclear to me how to follow the instructions relating to fontconfig.

Just to confirm, Is the instruction to set an environment variable before compilation, with a path of a yet to exist fonts.conf file, decided in advance? Any clues on what should be in the fonts.conf file?

Many thanks

@hiteshsondhi88

This comment has been minimized.

Show comment
Hide comment
@hiteshsondhi88

hiteshsondhi88 Aug 21, 2015

Member

@dominicthomas
Yes you need to environment variable first e.g "FONTCONFIG_FILE=/sdcard/fonts.conf"

You can check sample fontconfig files here - https://wiki.archlinux.org/index.php/Font_configuration#Example_fontconfig_configurations

Member

hiteshsondhi88 commented Aug 21, 2015

@dominicthomas
Yes you need to environment variable first e.g "FONTCONFIG_FILE=/sdcard/fonts.conf"

You can check sample fontconfig files here - https://wiki.archlinux.org/index.php/Font_configuration#Example_fontconfig_configurations

@dominicthomas

This comment has been minimized.

Show comment
Hide comment
@dominicthomas

dominicthomas Aug 21, 2015

Thanks. Also, given the error I received, I realised I'd forgotten the = after fontfile in the command arguments. Command completes successfully now but haven't been to able to create a playable video yet.

dominicthomas commented Aug 21, 2015

Thanks. Also, given the error I received, I realised I'd forgotten the = after fontfile in the command arguments. Command completes successfully now but haven't been to able to create a playable video yet.

@AndreaWozzup

This comment has been minimized.

Show comment
Hide comment
@AndreaWozzup

AndreaWozzup Jan 3, 2016

@hiteshsondhi88 Hi, I'm having a problem with "-vf subtitles" option for android ffmpeg. I have set the FONTCONFIG_FILE variable and indeed ffmpeg does not complain. Nevertheless the produced mp4 does not have any subs. I tried with attached fonts.conf file. Any suggestions?
fonts.zip

AndreaWozzup commented Jan 3, 2016

@hiteshsondhi88 Hi, I'm having a problem with "-vf subtitles" option for android ffmpeg. I have set the FONTCONFIG_FILE variable and indeed ffmpeg does not complain. Nevertheless the produced mp4 does not have any subs. I tried with attached fonts.conf file. Any suggestions?
fonts.zip

@AndreaWozzup

This comment has been minimized.

Show comment
Hide comment
@AndreaWozzup

AndreaWozzup Jan 3, 2016

@hiteshsondhi88 never mind resolved, it was actually a silly question. attached a android working fonts.conf, pointing to /system/fonts. Only issue is that ffmpeg try to use Arial and falls back to something else, but that's totally ok. Maybe I can put arial.ttf in my app and set a different dir for the font.
fontsconfandroid.zip

AndreaWozzup commented Jan 3, 2016

@hiteshsondhi88 never mind resolved, it was actually a silly question. attached a android working fonts.conf, pointing to /system/fonts. Only issue is that ffmpeg try to use Arial and falls back to something else, but that's totally ok. Maybe I can put arial.ttf in my app and set a different dir for the font.
fontsconfandroid.zip

@es-andreev

This comment has been minimized.

Show comment
Hide comment
@es-andreev

es-andreev Apr 9, 2016

@hiteshsondhi88 Hi! I have compiled ffmpeg with FONTCONFIG_FILE provided, and I successfully run with adb run-as my_package
/data/data/my_package/files/ffmpeg -i /data/data/my_package/files/file.mp4 -vf drawtext="fontfile=/data/data/my_package/files/my_font.ttf:text=test" /data/data/my_package/files/tmp.gif
but when I try to exec command
"/data/data/my_package/files/ffmpeg"
"-i"
"/data/data/my_package/files/file.mp4"
"-vf"
"drawtext="fontfile=/data/data/my_package/files/my_font.ttf:text=test""
"/data/data/my_package/files/tmp.gif"
I get
[Parsed_drawtext_0 @ 0xb81c3380] Could not load font ""fontfile=/data/data/my_package/files/my_font.ttf": cannot open resource
Fontconfig error: Cannot load default config file
[Parsed_drawtext_0 @ 0xb81c3380] Cannot find a valid font for the family Sans
[AVFilterGraph @ 0xb81bcd30] Error initializing filter 'drawtext' with args '"fontfile=/data/data/my_package/files/my_font.ttf:text=test"'
Error opening filters!

Have any suggestions?

es-andreev commented Apr 9, 2016

@hiteshsondhi88 Hi! I have compiled ffmpeg with FONTCONFIG_FILE provided, and I successfully run with adb run-as my_package
/data/data/my_package/files/ffmpeg -i /data/data/my_package/files/file.mp4 -vf drawtext="fontfile=/data/data/my_package/files/my_font.ttf:text=test" /data/data/my_package/files/tmp.gif
but when I try to exec command
"/data/data/my_package/files/ffmpeg"
"-i"
"/data/data/my_package/files/file.mp4"
"-vf"
"drawtext="fontfile=/data/data/my_package/files/my_font.ttf:text=test""
"/data/data/my_package/files/tmp.gif"
I get
[Parsed_drawtext_0 @ 0xb81c3380] Could not load font ""fontfile=/data/data/my_package/files/my_font.ttf": cannot open resource
Fontconfig error: Cannot load default config file
[Parsed_drawtext_0 @ 0xb81c3380] Cannot find a valid font for the family Sans
[AVFilterGraph @ 0xb81bcd30] Error initializing filter 'drawtext' with args '"fontfile=/data/data/my_package/files/my_font.ttf:text=test"'
Error opening filters!

Have any suggestions?

@es-andreev

This comment has been minimized.

Show comment
Hide comment
@es-andreev

es-andreev Apr 10, 2016

Removed double quotes in
drawtext="fontfile=/data/data/my_package/files/my_font.ttf:text=test"
and that worked. Text with spaces should be placed in single quotes.

es-andreev commented Apr 10, 2016

Removed double quotes in
drawtext="fontfile=/data/data/my_package/files/my_font.ttf:text=test"
and that worked. Text with spaces should be placed in single quotes.

@Jagdeep-Sing

This comment has been minimized.

Show comment
Hide comment
@Jagdeep-Sing

Jagdeep-Sing Dec 15, 2017

How to use this FONTCONFIG_FILE. can anyone explain step by step please because i stucked in my android project when i use drawtext filter and i really dont know how to use this configuration. i am begginer to it. can someone help here?

Jagdeep-Sing commented Dec 15, 2017

How to use this FONTCONFIG_FILE. can anyone explain step by step please because i stucked in my android project when i use drawtext filter and i really dont know how to use this configuration. i am begginer to it. can someone help here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment