You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MoviePy中SubtitlesClip无法识别任何指定字体的问题求助

MoviePy中SubtitlesClip无法识别任何指定字体的问题求助

我最近在尝试用MoviePy给视频添加字幕,但不管怎么调整操作,都会碰到同一个错误。以下是我使用的代码:

from moviepy import TextClip
from moviepy.video.tools.subtitles import SubtitlesClip
...
generator = lambda txt: TextClip(
    text = self.txt,
    font = self.font_path,
    font_size = 100,
    color= self.text_color,
    stroke_color="black",
    stroke_width=5,
)
subtitles = SubtitlesClip(self.subtitles_path, generator)

其中self.font_path目前是字符串"/fonts/my_font.otf",但不管我换成哪种字体,都会出现下面这条错误提示:

ValueError: Invalid font <function _spyderpdb_code.<locals>.<lambda> at 0x7b89f4d60e00>, pillow failed to use it with error 'function' object has no attribute 'read'

备注:内容来源于stack exchange,提问作者Oti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 15:48:00