Skip to content

Commit

Permalink
Merge pull request #656 from gyglim/master
Browse files Browse the repository at this point in the history
Fixes #655
  • Loading branch information
tburrows13 committed Oct 12, 2017
2 parents 00fe917 + 01ebcc3 commit a744df1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion moviepy/video/io/ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,16 @@ def get_frame(self, t):

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 (pos < self.pos) or (pos > self.pos + 100):
self.initialize(t)
self.pos = pos
else:
Expand Down
13 changes: 12 additions & 1 deletion tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
next(v.subclip(*subclip).iter_frames())
assert True



if __name__ == '__main__':
pytest.main()

0 comments on commit a744df1

Please sign in to comment.