[Python] MoviePy SubtitlesClip will not accept any provided font (Python)

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I am currently trying out moviepy to burn subtitles on a video. However I keep getting the same error message no matter what I do. This is the code I am using:

    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)


    where self.font_path is currently the string "/fonts/my_font.otf". Regardless of the font however, I keep getting the error message:

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

    Continue reading...

Compartilhe esta Página