我正在尝试使用FFmpeg从使用drawtext
(filter_complex
使用)注释/写入文本的图像创建视频。
如果drawtext
过滤器数量超过500,则会收到错误消息:
找不到适合家庭Sans的有效字体
FFmpeg显然对可以同时打开的字体文件数量有限制。
- 如何
drawtext
工作-为什么一个新的文件打开每个过滤器,即使所有的字体文件是一样的吗? - 有什么办法解决这个问题?通过增加可以同时打开的文件的限制?
drawtext
文档有一个选项fontconfig
-如何使用?在上述情况下有帮助吗?
完整的命令
ffmpeg -f concat -i input.txt -i input_audio.wav -y -r 10 -filter_complex_script filterCommand.txt -crf 22 -threads 2 -preset ultrafast output_video.mp4
-filterCommand.txt-文本文件包含drawtext=enable='between(n,0,0)':fontsize=10:fontfile='C\:/windows/Fonts/calibrib.ttf':fontcolor='0x000000
逗号分隔-重复509次DrawText有效
509次,失败510次。
控制台日志
ffmpeg version N-81989-g7845c13 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. 32.100 / 55. 32.100
libavcodec 57. 61.103 / 57. 61.103
libavformat 57. 52.100 / 57. 52.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 64.100 / 6. 64.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 2.100 / 2. 2.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, concat, from 'temp/test4/node-5303540733531691237.txt':
Duration: 00:00:01.61, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, wav, from 'temp/32_anonymoususer1825804750300631765/part/1_subPart/audio/part_audio.wav':
Duration: 00:00:09.50, bitrate: 705 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Fontconfig error: Cannot load default config file
[Parsed_drawtext_509 @ 000000000a4ca9a0] Cannot find a valid font for the family Sans
[AVFilterGraph @ 0000000000b8cfc0] Error initializing filter 'drawtext' with args 'enable=between(n,21,21):fontsize=10:fontfile=C\:/windows/Fonts/calibrib.ttf:fontcolor=0x000000:text=100\.0:x=398:y=119-th'
Error initializing complex filters.
No such file or directory
ffmpeg -f concat -i input.txt -i input_audio.wav -y -r 10 -vf "drawtext=enable='between(n,0,0)':fontsize=10:fontfile='C\:/windows/Fonts/calibrib.ttf':fontcolor='0x000000':text='120\.0':x=480:y=61-th" -crf 22 -threads 2 -preset ultrafast output_video.mp4
--重复执行