如何修复“使用react-native-ffmpeg在图像上添加文本时找不到 Sans 系列的有效字体”

问题描述 投票:0回答:2

我正在尝试使用下面的代码在图像上添加文本 RNFFmpeg .执行(

`-y -i ${input} -vf "drawtext=text='Hello World':fontcolor=white:fontsize=75:x=0:y=0" ${output}`
);

我没有使用任何自定义字体,但仍然收到此错误。

错误:

[Parsed_drawtext_0 @ 0x7f87a1ce40] 找不到 Sans 系列的有效字体

index.js:115 [AVFilterGraph @ 0x7f6765e760] 初始化过滤器“drawtext”时出错 index.js:115 [AVFilterGraph @ 0x7f6765e760] 带有参数 'text=Hello World:fontcolor=white:fontsize=75:x=0:y=0' index.js:115 [AVFilterGraph @ 0x7f6765e760]

index.js:115 重新初始化过滤器时出错!

index.js:115 无法将帧注入过滤器网络:没有这样的文件或目录

index.js:115 处理流 #0:0 的解码数据时出错

注:

我也尝试过使用自定义字体,但无法做到。 当我使用 RNFFmpegConfig.setFontDirectory('../../assets/fonts') 函数并使用以下代码在图像上添加文本时 RNFFmpeg .执行(

`-y -i ${input} -vf "drawtext=text='Hello World':fontfile='../../assets/fonts/MyFont.ttf':fontcolor=white:fontsize=75:x=0:y=0" ${output}`
);

它给了我同样的错误。

我该如何解决这个问题。

react-native ffmpeg
2个回答
0
投票

根据这个 https://github.com/tanersener/ffmpeg-kit/wiki/Tips

您应该使用

FFmpegKitConfig.setFontDirectory
方法在目录下注册字体,或者使用
FFmpegKitConfig.setFontconfigConfigurationPath

指定您自己的 fontconfig 配置

Android 上的系统字体存储在

/system/fonts folder
下 在 iOS 上,存储在
/System/Library/Fonts


0
投票

你找到了吗?这个问题的答案,因为我被困在这个问题上

© www.soinside.com 2019 - 2024. All rights reserved.