Zulko / moviepy

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

TypeError: cannot unpack non-iterable NoneType object #2106

Open sugizo opened 5 months ago

sugizo commented 5 months ago

Expected Behavior

can use subtitle moviepy tools

Actual Behavior

have an error when using subtitle moviepy tools

TypeError                                 Traceback (most recent call last)
[<ipython-input-205-c62f492ebac5>](https://localhost:8080/#) in <cell line: 1>()
----> 1 sub = SubtitlesClip("subtitle.srt", generator)

1 frames
[/usr/local/lib/python3.10/dist-packages/moviepy/video/tools/subtitles.py](https://localhost:8080/#) in <listcomp>(.0)
     53         self.make_textclip = make_textclip
     54         self.start=0
---> 55         self.duration = max([tb for ((ta,tb), txt) in self.subtitles])
     56         self.end=self.duration
     57 

TypeError: cannot unpack non-iterable NoneType object

Steps to Reproduce the Problem

!wget -c https://cdn.creatomate.com/demo/mountains.mp4
f = open("subtitle.srt", "w")
f.write("""
1
00:00:00,000 --> 00:00:01,500
good

2
00:00:01,500 --> 00:00:02,500
<i>great</i>

3
00:00:03,000 --> 00:00:6,000
<b>best</b>
""")
f.close()
pip install -U moviepy 
from moviepy.editor import *
from moviepy.video.tools.subtitles import SubtitlesClip
video0 = VideoFileClip("mountains.mp4")
generator = lambda txt: TextClip(txt, font = 'Georgia-Regular', fontsize = 24, color = 'white')
sub = SubtitlesClip("subtitle.srt", generator)

Specifications

thanks and best regards

gerappa01 commented 3 months ago

exact same issue. Did you manage to resolve it?

Praj-17 commented 3 months ago

I am facing the exact same issue, This is how my srt file looks like.

1
0:00:00 --> 0:00:03
Esta es la IA, presentada por IBM.

2
0:00:03 --> 0:00:04
Empieza ahora.

3
0:00:06.500000 --> 0:00:09.400000
La inteligencia artificial está aquí, nos guste o no.

4
0:00:09.400000 --> 0:00:11.100000
Inteligencia artificial.

5
0:00:11.100000 --> 0:00:12.100000
Aprendizaje automático.

6
0:00:12.100000 --> 0:00:13
Robots.

7
0:00:13 --> 0:00:15.100000
Es emocionante y también muy aterrador.

8
0:00:15.100000 --> 0:00:17.700000
Algunos de los nombres más importantes de la ciencia y la tecnología.

9
0:00:17.700000 --> 0:00:21.400000
Advierten sobre los peligros del uso de inteligencia artificial.
PigeonCai commented 13 hours ago

hi ,guys ,I found the same error ,when i try to load srt file.

Deep dive the source code ,

moviepy use this methods to parse srt ”moviepy.video.tools.subtitles.file_to_subtitles “ the code to find each subtitle in the file is :

times = re.findall("([0-9]:[0-9]:[0-9],[0-9])", line)

In my case,the problem sloved just replace all "." with "," .