ffmpeg-kit icon indicating copy to clipboard operation
ffmpeg-kit copied to clipboard

Flutter : Cannot find a valid font for the family Sans

Open jack84156 opened this issue 3 years ago • 8 comments
trafficstars

here is my steps 1- i have added font to the following track /storage/emulated/0/Download/fonts/Roboto-Black.ttf (i download the font from [](https://fonts.google.com/))

2- i called the following method to set my font like following await FFmpegKitConfig.setFontDirectory('/storage/emulated/0/Download/fonts');

3- i called the following command String comand = '-y -i $videoPath -i $imagePath -filter_complex "[1]scale=600:600[i1];[0][i1]overlay=200:200,drawtext=fontfile=Roboto-Black.ttf:text=\'Stack Overflow\':fontcolor=white:fontsize=24:box=1:[email protected]:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2" -shortest -qscale 0 $outPutPath';

i got the following errors

[Parsed_drawtext_2 @ 0xb4000075bcb0d900] Cannot find a valid font for the family Sans

[log] [AVFilterGraph @ 0xb40000779a3e9580] Error initializing filter 'drawtext'
[log] [AVFilterGraph @ 0xb40000779a3e9580]  with args 'fontfile=kskss.ttf:text=Stack Overflow:fontcolor=white:fontsize=24:box=1:[email protected]:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2'
[log] [AVFilterGraph @ 0xb40000779a3e9580] 

[log] Error initializing complex filters.

[log] No such file or directory

[log] ERRORr

Note : in my previous command , when i replace fontfile=Roboto-Black.ttf to fontfile= /system/fonts/Roboto-Regular it work correctly

i am using the following release ffmpeg_kit_flutter_full: ^5.1.0

Flutter android device

where is my mistake ?

jack84156 avatar Oct 14 '22 09:10 jack84156

FFmpegKitConfig.setFontDirectory sets the font path in a fontconfig configuration. But, as far as I know the fontfile option is a filter level option and cannot use fontconfig. Can you try either of these two?

  1. Giving the full path in fontfile
  2. Use the font option and let fontconfig do the name to font file mapping

tanersener avatar Oct 14 '22 13:10 tanersener

i tried the following drawtext=fontfile=/storage/emulated/0/Download/font/Roboto-Black.ttf:text=........etc

i aslo tried drawtext=/storage/emulated/0/Download/font/Roboto-Black.ttf:text=........etc

i also tried

await FFmpegKitConfig.setFontDirectory('/storage/emulated/0/Download/font');
drawtext=font=Roboto-Black.ttf:text=........etc 

i also tried

await FFmpegKitConfig.setFontDirectory('/storage/emulated/0/Download/font',{'myFont':'Roboto-Black.ttf'});
drawtext=font=myFont:text=........etc 

without any luck i am getting the same error message as well .

I also used other fonts without any luck

jack84156 avatar Oct 15 '22 04:10 jack84156

I don't know exactly what went wrong in all your tests. But, I do see that Roboto-Black.ttf is used as font name, which won't work. Roboto Black must be as name.

I ran some tests and didn't see any errors when font='Roboto Black' or fontname=<full font path> is used.

You can run my tests locally if you run flutter/test-app-pub application in the example-issue-597 branch of ffmpeg-kit-test repository. Video tab includes my tests.

tanersener avatar Oct 15 '22 09:10 tanersener

Literally and meticulously I implemented all of what you said, even I copied your tests in that example folder but without any luck.

The thing that makes me sure that there is nothing wrong is that when I use fontfile= /system/fonts/Roboto-Regular Which is the default font path for Android it work fine .

I'm really totally confused . cannot find obvious reason!!!

jack84156 avatar Oct 15 '22 11:10 jack84156

Maybe this is just an Android permission issue. That folder is not an application folder. I suggest checking whether you can access the fonts inside that folder or not.

tanersener avatar Oct 15 '22 11:10 tanersener

How to use drawtext in Flutter Android?I get an Error when I use drawtext. Command: -ss 0:00:00.000000 -i $inputPath -t 0:00:18.393000 -avoid_negative_ts make_zero -c:a copy -an -vf drawtext=enable=text="helloWorld1":fontcolor=#ffffff:fontsize=24:x=(w-text_w)/2:y=(h-text_h)/2 -c:v libx264 $outputPath Error Msg: Loaded ffmpeg-kit-flutter-android-full-gpl-arm64-v8a-5.1.0-lts. FFmpeg process exited with state COMPLETED and rc 1 FFmpeg processing failed. Couldn't save the video

ZHUMINGZHE123 avatar Dec 08 '22 18:12 ZHUMINGZHE123

i also facing error with drawtext.

FFmpeg start process with command = -i /data/user/0/com.example.example/cache/df917e45-0d21-4aeb-b471-975940d90639/VID-20230629-WA0004.mp4 -filter_complex '[0:v]drawtext=text=Hello, World!:fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2' /data/user/0/com.example.example/cache/VID-20230629-WA0004_1688409974333.mp4 [log] Exception: FFmpeg process exited with state COMPLETED and return code 1. ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d) configuration: --cross-prefix=arm-linux-androideabi- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm-neon/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=armv7-a --cpu=armv7-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --build-suffix=_neon --ar=arm-linux-androideabi-ar --cc=armv7a-linux-androideabi24-clang --cxx=armv7a-linux-androideabi24-clang++ --ranlib=arm-linux-androideabi-ranlib --strip=arm-linux-androideabi-strip --nm=arm-linux-androideabi-nm --extra-libs='-L/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm-neon/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-sdl2 --disable-openssl --enable-zlib --enable-mediacodec libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.example.example/cache/df917e45-0d21-4aeb-b471-975940d90639/VID-20230629-WA0004.mp4': Metadata: major_brand : mp4v minor_version : 0 compatible_brands: mp4vmp42isom Duration: 00:00:02.28, start: 0.000000, bitrate: 724 kb/s Stream #0:00x1: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt470bg/smpte170m, progressive), 400x864, 718 kb/s, 25.44 fps, 120 tbr, 90k tbn (default) Metadata: vendor_id : [0][0][0][0] [AVFilterGraph @ 0xc10ce100] No such filter: 'drawtext' Error initializing complex filters. Invalid argument

himanshudeveloper avatar Jul 03 '23 18:07 himanshudeveloper

Is there any fix for this? I am also facing the same issue. I am not able to implement drawtext filter at all.

Thank you.

krupal811 avatar Dec 06 '23 15:12 krupal811

See #4 and #9 in Tips if you're having trouble with drawtext.

tanersener avatar Apr 10 '24 12:04 tanersener