Skip to content

Video editing with Python

Fixed bug: crash when exiting previews with escape

Zulko6b0169b2ab34
diff --git a/moviepy/audio/io/preview.py b/moviepy/audio/io/preview.py
index 6c62d135..a6f8f717 100644
--- a/moviepy/audio/io/preview.py
+++ b/moviepy/audio/io/preview.py
@@ -58,4 +58,8 @@ def preview(clip, fps=22050, buffersize=50000, nbytes= 2,
chunk = pg.sndarray.make_sound(sndarray)
while channel.get_queue():
time.sleep(0.003)
+ if not videoFlag.is_set():
+ channel.stop()
+ del channel
+ return
channel.queue(chunk)
diff --git a/moviepy/video/fx/mirror_x.py b/moviepy/video/fx/mirror_x.py
index 5dab6966..217d1c50 100644
--- a/moviepy/video/fx/mirror_x.py
+++ b/moviepy/video/fx/mirror_x.py
@@ -1,5 +1,5 @@
-def mirror_x(clip, apply_to= "mask"):
+def mirror_x(clip, applyto= "mask"):
""" flips the clip horizontally (and its mask too, by default) """
return clip.fl_image(lambda gf, t: gf(t)[:,::-1],
- apply_to = apply_to)
+ applyto = applyto)
diff --git a/moviepy/video/fx/mirror_y.py b/moviepy/video/fx/mirror_y.py
index fe714bfb..2414cb24 100644
--- a/moviepy/video/fx/mirror_y.py
+++ b/moviepy/video/fx/mirror_y.py
@@ -1,4 +1,4 @@
def mirror_y(clip, apply_to= "mask"):
""" flips the clip vertically (and its mask too, by default) """
return clip.fl_image(lambda gf, t : gf(t)[::-1],
- apply_to = apply_to)
+ applyto = applyto)
diff --git a/moviepy/video/fx/time_mirror.py b/moviepy/video/fx/time_mirror.py
index 75350270..ed53dad4 100644
--- a/moviepy/video/fx/time_mirror.py
+++ b/moviepy/video/fx/time_mirror.py
@@ -12,14 +12,3 @@ def time_mirror(self):
The same effect is applied to the clip's audio and mask if any.
"""
return self.fl_time(lambda t: self.duration - t, keep_duration=True)
-
-
-@requires_duration
-@apply_to_mask
-@apply_to_audio
-def loop(self):
- """
- Returns a clip that plays the current clip in an infinite loop.
- Ideal for clips coming from gifs.
- """
- return self.fl_time(lambda t: t % self.duration)
diff --git a/moviepy/video/io/preview.py b/moviepy/video/io/preview.py
index 54a4cc07..337d4a72 100644
--- a/moviepy/video/io/preview.py
+++ b/moviepy/video/io/preview.py
@@ -94,8 +94,7 @@ def preview(clip, fps=15, audio=True, audio_fps=22050,
for event in pg.event.get():
if event.type == pg.KEYDOWN:
if (event.key == pg.K_ESCAPE):
- pg.mixer.stop()
- pg.mixer.quit()
+ videoFlag.clear()
print "Keyboard interrupt"
return