Skip to content

Video editing with Python

Fix `AttributeError: 'NoneType' object has no attribute 'stdout'` for all versions of Python (#1185) Release v1.0.3

Tom Burrowsdd5aa72c84b9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34c5271a..58087230 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `AudioFileClip` would not generate audio identical to the original file [#1108]
+## [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 58dcacf6..dfa413a7 100644
--- a/moviepy/audio/io/AudioFileClip.py
+++ b/moviepy/audio/io/AudioFileClip.py
@@ -93,6 +93,3 @@ class AudioFileClip(AudioClip):
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 58042a8d..9271cd13 100644
--- a/moviepy/audio/io/readers.py
+++ b/moviepy/audio/io/readers.py
@@ -164,6 +164,7 @@ class FFMPEG_AudioReader:
self.proc.terminate()
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/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py
index 17fe242f..652bc036 100644
--- a/tests/test_VideoFileClip.py
+++ b/tests/test_VideoFileClip.py
@@ -44,5 +44,23 @@ 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()