Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.16k stars 1.52k forks source link

SubtitlesClip #777

Closed lifeNrun closed 6 years ago

lifeNrun commented 6 years ago

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 commented 6 years ago

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

jpaguilarc99 commented 1 year ago

Please tell me how did u fix the file

MASSKAgithub commented 5 months ago

Same error

Souks commented 5 months ago

and same here too

MASSKAgithub commented 5 months ago

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 commented 5 months ago

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