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 #777

Closed
lifeNrun opened this issue Apr 26, 2018 · 6 comments
Closed

SubtitlesClip #777

lifeNrun opened this issue Apr 26, 2018 · 6 comments

Comments

@lifeNrun
Copy link

lifeNrun commented Apr 26, 2018

Hi, When I use SubtitlesClip to set subtitle for video. I got these failed error message below:

Traceback (most recent call last):
  File "musicChina.py", line 67, in <module>
    subtitles = SubtitlesClip("./prepare/test.srt", generator)
  File "C:\Python36\lib\site-packages\moviepy\video\tools\subtitles.py", line 54, in __init__
    self.duration = max([tb for ((ta,tb), txt) in self.subtitles])
  File "C:\Python36\lib\site-packages\moviepy\video\tools\subtitles.py", line 54, in <listcomp>
    self.duration = max([tb for ((ta,tb), txt) in self.subtitles])
TypeError: 'NoneType' object is not iterable

This is my code:

    font="ArialUnicode"
    color='red'
    generator = lambda txt: TextClip(txt, font=font, fontsize=40, color=color)
    subtitles = SubtitlesClip("./prepare/test.srt", generator)

Thanks.

@lifeNrun
Copy link
Author

Problem solved. The srt file has problem. Please igore this.

@jpaguilarc99
Copy link

Please tell me how did u fix the file

@MASSKAgithub
Copy link

Same error

@Souks
Copy link

Souks commented Feb 4, 2024

and same here too

@MASSKAgithub
Copy link

I FOUND A SOLUTION

The spacing between EACH str block, should be 1 new line, and at the end of the file should be 2 new lines
ALSO Sometimes, in my generated SRT files, there are blocks that are for no reason: 00:00:00 in the middle of the file, so you have to remove them (with their number and text if it has, usually it doesn't have any text)

And so by applying this modifications the file becomes usable!

@Souks
Copy link

Souks commented Feb 4, 2024

Thanks for the help, i had 3 new line at the end of the file and it was my error ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants