[英]FFmpeg android - Fontconfig error : Cannot load default config file
[英]Android - how to register a new FontConfig using FFmpegKitConfig.setFontDirectory
我正在使用ffmpeg-kit將字幕刻錄成 mp4 文件,根據他們在這里的提示,我需要在Android
下注冊字體或指定fontconfig
配置,但我不知道該怎么做。
在提示中,他們建議使用FFmpegKitConfig.setFontDirectory
注冊一個新的 FontConfig,所以我嘗試編寫以下代碼:
String cmd = "-i " + videoPath + " -vf subtitles=\"" + subtitlePAth + ":force_style='Alignment=10,Fontsize=18\" " +
outputVideoPath;
Map<String, String> mapping= new HashMap<String, String>();
mapping.put("fontName.ttf", "fontName");
FFmpegKitConfig.setFontDirectory(getApplicationContext(),fontDirectoyPath,mapping);
FFmpegKit.executeAsync(cmd, new FFmpegSessionCompleteCallback() {
@Override
public void apply(FFmpegSession session) {
}
}, new LogCallback() {
@Override
public void apply(com.arthenica.ffmpegkit.Log log) {
}
}, new StatisticsCallback() {
@Override
public void apply(Statistics statistics) {
}
});`
但是在運行此代碼時我仍然收到此日志
[Parsed_subtitles_0 @ 0xe4bc04c0] Using font provider fontconfig[Parsed_subtitles_0 @ 0xe4bc04c0]
[Parsed_subtitles_0 @ 0xe4bc04c0] fontselect: failed to find any fallback with glyph 0x0 for font: (Arial, 400, 0)[Parsed_subtitles_0 @ 0xe4bc04c0]
有什么想法嗎?
您沒有在force_style
指令中指定字體。 嘗試在那里添加一個FontName=fontName
選項。
此外,我沒有看到您使用的實際值,但您的字體名稱映射也可能不正確。 字體名稱映射具有customName
-> realName
格式。 您的示例將fontName.ttf
設置為自定義,這很好,但也有點奇怪。 它的末尾有一個擴展名。 如果這是給定的值,則force_style
指令必須具有FontName=fontName.ttf
。
ffmpeg-kit
在https://github.com/tanersener/ffmpeg-kit-test有一個用於測試應用程序的單獨存儲庫。 那里提供的測試應用程序有一個字幕選項卡來測試刻錄字幕。 你可以看到FFmpegKitConfig.setFontDirectory
是如何被調用和使用的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.