From db19920764b5cb1d8aa6863019544fd8ae0d3cce Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Thu, 7 May 2020 17:26:59 +0100 Subject: [PATCH] Fix `AttributeError: 'NoneType' object has no attribute 'stdout'` for all versions of Python (#1185) --- CHANGELOG.md | 7 +++++++ moviepy/audio/io/AudioFileClip.py | 3 --- moviepy/audio/io/readers.py | 1 + moviepy/version.py | 2 +- tests/test_VideoFileClip.py | 17 +++++++++++++++++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60e70db2c..d672e8884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [v1.0.3](https://github.com/zulko/moviepy/tree/v1.0.3) (2020-05-07) + +[Full Changelog](https://github.com/zulko/moviepy/compare/v1.0.2...v1.0.3) + +Bonus release to fix critical error when working with audio: `AttributeError: 'NoneType' object has no attribute 'stdout'` [\#1185](https://github.com/Zulko/moviepy/pull/1185) + + ## [v1.0.2](https://github.com/zulko/moviepy/tree/v1.0.2) (2020-03-26) [Full Changelog](https://github.com/zulko/moviepy/compare/v1.0.1...v1.0.2) diff --git a/moviepy/audio/io/AudioFileClip.py b/moviepy/audio/io/AudioFileClip.py index e93dbb04c..b79ab23d0 100644 --- a/moviepy/audio/io/AudioFileClip.py +++ b/moviepy/audio/io/AudioFileClip.py @@ -88,6 +88,3 @@ def close(self): if self.reader: self.reader.close_proc() self.reader = None - - def __del__(self): - self.close() diff --git a/moviepy/audio/io/readers.py b/moviepy/audio/io/readers.py index cfecc826b..991e60bb3 100644 --- a/moviepy/audio/io/readers.py +++ b/moviepy/audio/io/readers.py @@ -150,6 +150,7 @@ def close_proc(self): for std in [ self.proc.stdout, self.proc.stderr]: std.close() + self.proc.wait() self.proc = None def get_frame(self, tt): diff --git a/moviepy/version.py b/moviepy/version.py index 7863915fa..976498ab9 100644 --- a/moviepy/version.py +++ b/moviepy/version.py @@ -1 +1 @@ -__version__ = "1.0.2" +__version__ = "1.0.3" diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py index 1dc448736..17825cb31 100644 --- a/tests/test_VideoFileClip.py +++ b/tests/test_VideoFileClip.py @@ -44,5 +44,22 @@ def test_ffmpeg_resizing(): video.close() +def test_shallow_copy(): + """Call a function which uses @outplace + and verify that making a shallow copy and deleting it + does not corrupt the original clip.""" + video_file = 'media/big_buck_bunny_0_30.webm' + video = VideoFileClip(video_file) + video_copy = video.set_start(1) + del video_copy + # The clip object buffers 200000 frames, around 5 seconds ahead. + # When recentering the buffer, if the new buffer is more than 1000000 frames, around 25s + # ahead of the end of the current buffer, the reader will reinitialize and fix self.proc + # Thus to trigger the bug, you have to look for a frame between ~5 and ~30 seconds away. + # These numbers might vary for different reasons and it would be nice to have a test + # which was robust to changes in default buffer size, etc. + video.audio.make_frame(15) + + if __name__ == '__main__': pytest.main()