77# MoviePy
88try :
99 from moviepy .video .io .VideoFileClip import VideoFileClip
10- from moviepy .tools import cvsecs
1110 import numpy as np
1211except ImportError as e :
1312 print ("""Error importing dependencies:
@@ -126,6 +125,8 @@ def reset(self):
126125 self .status = UNINITIALIZED
127126 self .clock .reset ()
128127
128+ self .loop_count = 0
129+
129130 def load_media (self , mediafile , play_audio = True ):
130131 """ Loads a media file to decode.
131132
@@ -323,7 +324,8 @@ def seek(self, value):
323324 """
324325 # Pause the stream
325326 self .pause ()
326- self .clock .time = value
327+ # Make sure the movie starts at 1s as 0s gives trouble.
328+ self .clock .time = max (0.5 , value )
327329 logger .debug ("Seeking to {} seconds; frame {}" .format (self .clock .time ,
328330 self .clock .current_frame ))
329331 if self .audioformat :
@@ -334,7 +336,7 @@ def seek(self, value):
334336 def rewind (self ):
335337 """ Rewinds the video to the beginning.
336338 Convenience function simply calling seek(0). """
337- self .seek (0 )
339+ self .seek (0.5 )
338340
339341 def __calculate_audio_frames (self ):
340342 """ Aligns audio with video.
@@ -374,7 +376,8 @@ def __render(self):
374376 if self .loop :
375377 logger .debug ("Looping: restarting stream" )
376378 # Seek to the start
377- self .seek (0 )
379+ self .rewind ()
380+ self .loop_count += 1
378381 else :
379382 # End of stream has been reached
380383 self .status = EOS
0 commit comments