Skip to content

Video editing with Python

Support for SRT files with any kind of newline

John Hayes28d9f45d98c2
diff --git a/moviepy/video/tools/subtitles.py b/moviepy/video/tools/subtitles.py
index 5e8fada3..112a2a02 100644
--- a/moviepy/video/tools/subtitles.py
+++ b/moviepy/video/tools/subtitles.py
@@ -158,9 +158,9 @@ def file_to_subtitles(filename):
times = re.findall("([0-9]*:[0-9]*:[0-9]*,[0-9]*)", line)
if times != []:
current_times = map(cvsecs, times)
- elif line == '\n':
+ elif line.strip() == '':
times_texts.append((current_times, current_text.strip('\n')))
current_times, current_text = None, ""
elif current_times is not None:
current_text = current_text + line
- return times_texts
\ No newline at end of file
+ return times_texts