Skip to content

Commit

Permalink
Fixed 'clip.preview()' crashing at exit when running inside Jupyter N…
Browse files Browse the repository at this point in the history
…otebook in Windows (Zulko#1537)

* Update preview.py, fix issue Zulko#575

Fixed issue Zulko#575. Added two pg.quit statements at lines 146 and 162. For line 146, this statement adds quit functionality for " event.type == pg.KEYDOWN and event.key == pg.K_ESCAPE". This allows the window to close whenever the event triggers. For line 162, once the for loop ends (the video ends), the window closes instead of crashing.

Co-authored-by: jacobwhiteman17 <54951159+jacobwhiteman17@users.noreply.github.com>
  • Loading branch information
Victrollia and jacobwhiteman17 committed Apr 15, 2021
1 parent 778233d commit 2f7e434
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `Clip.cutout` transformation not being applied to audio [\#1468](https://github.com/Zulko/moviepy/pull/1468)
- Fixed arguments inconsistency in `video.tools.drawing.color_gradient` [\#1467](https://github.com/Zulko/moviepy/pull/1467)
- Fixed `fps` not defined in `CompositeAudioClip` at initialization [\#1462](https://github.com/Zulko/moviepy/pull/1462)
- Fixed `clip.preview()` crashing at exit when running inside Jupyter Notebook in Windows [\#1537](https://github.com/Zulko/moviepy/pull/1537)


## [v2.0.0.dev2](https://github.com/zulko/moviepy/tree/v2.0.0.dev2) (2020-10-05)
Expand Down
3 changes: 3 additions & 0 deletions moviepy/video/io/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def preview(
if audio:
video_flag.clear()
print("Interrupt")
pg.quit()
return result

elif event.type == pg.MOUSEBUTTONDOWN:
Expand All @@ -157,3 +158,5 @@ def preview(
t1 = time.time()
time.sleep(max(0, t - (t1 - t0)))
imdisplay(img, screen)

pg.quit()

0 comments on commit 2f7e434

Please sign in to comment.