Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubtitlesClip TypeError: 'float' object cannot be interpreted as an integer #2305

Closed
yeohongred opened this issue Dec 29, 2024 · 2 comments
Closed
Labels
bug Issues that report (apparent) bugs.

Comments

@yeohongred
Copy link
Contributor

Trying to create a SubtitlesClip without make_textclip() causes a TypeError

Steps to Reproduce the Problem

from moviepy.video.tools.subtitles import SubtitlesClip
from moviepy import VideoFileClip, CompositeVideoClip

video = VideoFileClip(filename="video.mp4")
subtitles = SubtitlesClip(subtitles="subtitles.srt", font="font.otf") # ERROR
output = CompositeVideoClip([video, subtitles])
output.write_videofile("output.mp4", fps=24)
Traceback (most recent call last):
  File "c:\Users\Yeo Hong\Desktop\test\test.py", line 6, in <module>
    subtitles = SubtitlesClip(subtitles="subtitles.srt", font="font.otf")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\moviepy\video\tools\subtitles.py", line 123, in __init__
    hasmask = bool(self.make_textclip("T").mask)
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\moviepy\video\tools\subtitles.py", line 76, in make_textclip
    return TextClip(
           ^^^^^^^^^
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\moviepy\decorators.py", line 94, in wrapper
    return func(*new_args, **new_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\moviepy\video\VideoClip.py", line 1763, in __init__
    draw.multiline_text(
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\PIL\ImageDraw.py", line 775, in multiline_text
    self.text(
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\PIL\ImageDraw.py", line 690, in text
    draw_text(stroke_ink, stroke_width)
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\PIL\ImageDraw.py", line 635, in draw_text
    mask, offset = font.getmask2(  # type: ignore[union-attr,misc]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Yeo Hong\Desktop\test\.venv\Lib\site-packages\PIL\ImageFont.py", line 607, in getmask2
    return self.font.render(
           ^^^^^^^^^^^^^^^^^
TypeError: 'float' object cannot be interpreted as an integer

Specifications

  • Python Version: 3.12.4
  • MoviePy Version: v2.1.1
@yeohongred yeohongred added the bug Issues that report (apparent) bugs. label Dec 29, 2024
@q273255702
Copy link

the same is

OsaAjani added a commit that referenced this issue Jan 3, 2025
Fix issue #2305: Change stroke_width from float 0.5 to int 1
@OsaAjani
Copy link
Collaborator

OsaAjani commented Jan 3, 2025

Should be fixed by the new PR

@OsaAjani OsaAjani closed this as completed Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

3 participants