From 5e05a956c26b828a8338dba2ccfc68a6f2d292eb Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 2 Dec 2024 13:46:59 +0200 Subject: [PATCH 1/2] Correct SubtitlesClip example to not pass the generator lambda as `font` --- moviepy/video/tools/subtitles.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/moviepy/video/tools/subtitles.py b/moviepy/video/tools/subtitles.py index b240f2de4..ef181ad69 100644 --- a/moviepy/video/tools/subtitles.py +++ b/moviepy/video/tools/subtitles.py @@ -46,8 +46,7 @@ class SubtitlesClip(VideoClip): from moviepy.video.io.VideoFileClip import VideoFileClip generator = lambda text: TextClip(text, font='Georgia-Regular', font_size=24, color='white') - sub = SubtitlesClip("subtitles.srt", generator) - sub = SubtitlesClip("subtitles.srt", generator, encoding='utf-8') + sub = SubtitlesClip("subtitles.srt", make_textclip=generator, encoding='utf-8') myvideo = VideoFileClip("myvideo.avi") final = CompositeVideoClip([clip, subtitles]) final.write_videofile("final.mp4", fps=myvideo.fps) From ae799eac6ba2a479185214828dc86ccffbe42e40 Mon Sep 17 00:00:00 2001 From: Pierre-Lin Bonnemaison Date: Mon, 6 Jan 2025 00:02:38 +0100 Subject: [PATCH 2/2] Update subtitles.py Fix path to font too --- moviepy/video/tools/subtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moviepy/video/tools/subtitles.py b/moviepy/video/tools/subtitles.py index ef181ad69..7a1d4d1c1 100644 --- a/moviepy/video/tools/subtitles.py +++ b/moviepy/video/tools/subtitles.py @@ -44,7 +44,7 @@ class SubtitlesClip(VideoClip): from moviepy.video.tools.subtitles import SubtitlesClip from moviepy.video.io.VideoFileClip import VideoFileClip - generator = lambda text: TextClip(text, font='Georgia-Regular', + generator = lambda text: TextClip(text, font='./path/to/font.ttf', font_size=24, color='white') sub = SubtitlesClip("subtitles.srt", make_textclip=generator, encoding='utf-8') myvideo = VideoFileClip("myvideo.avi")