Skip to content

Video editing with Python

fix for issue #655

Michael Gygli46aae7b0f765
diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.py
index 82e5cb1a..150203e9 100644
--- a/moviepy/video/io/ffmpeg_reader.py
+++ b/moviepy/video/io/ffmpeg_reader.py
@@ -166,10 +166,16 @@ class FFMPEG_VideoReader:
pos = int(self.fps*t + 0.00001)+1
+ # Initialize proc if it is not open
+ if not self.proc:
+ self.initialize(t)
+ self.pos = pos
+ self.lastread = self.read_frame()
+
if pos == self.pos:
return self.lastread
else:
- if(pos < self.pos) or (pos > self.pos+100):
+ if not self.proc or (pos < self.pos) or (pos > self.pos + 100):
self.initialize(t)
self.pos = pos
else:
diff --git a/tests/test_issues.py b/tests/test_issues.py
index 7296917c..be367e83 100644
--- a/tests/test_issues.py
+++ b/tests/test_issues.py
@@ -285,7 +285,18 @@ def test_issue_636():
with VideoFileClip("media/big_buck_bunny_0_30.webm").subclip(0,11) as video:
with video.subclip(0,1) as subclip:
pass
-
+
+def test_issue_655():
+ video_file = 'media/fire2.mp4'
+ for subclip in [(0,2),(1,2),(2,3)]:
+ with VideoFileClip(video_file) as v:
+ with v.subclip(1,2) as s:
+ pass
+ v.subclip(*subclip).iter_frames().next()
+ assert True
+
+
+
if __name__ == '__main__':
pytest.main()