From a06402a904d039bf711341006db9d932838f616a Mon Sep 17 00:00:00 2001 From: jwg4 Date: Thu, 16 Jan 2020 01:04:54 +0000 Subject: [PATCH 1/8] Add a test which checks for killed audio reader. --- tests/test_VideoFileClip.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py index b2501224b..00ae2bc83 100644 --- a/tests/test_VideoFileClip.py +++ b/tests/test_VideoFileClip.py @@ -41,6 +41,17 @@ def test_ffmpeg_resizing(): assert target == observed 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_432_433.webm' + video = VideoFileClip(video_file) + video_copy = video.set_start(1) + del(video_copy) + video.audio.make_frame(2) + if __name__ == '__main__': pytest.main() From 18b36bdaf7c35431f25b6a8938b042853ffa7593 Mon Sep 17 00:00:00 2001 From: jwg4 Date: Thu, 16 Jan 2020 01:07:21 +0000 Subject: [PATCH 2/8] Don't explicitly close the proc in the reader. Don't shut down the reader - it could be shared between multiiple clip instances. Just unset it here and the GC should kill it when it's no longer referenced anywhere. --- moviepy/audio/io/AudioFileClip.py | 1 - 1 file changed, 1 deletion(-) diff --git a/moviepy/audio/io/AudioFileClip.py b/moviepy/audio/io/AudioFileClip.py index 8ab3ad81b..09eca0404 100644 --- a/moviepy/audio/io/AudioFileClip.py +++ b/moviepy/audio/io/AudioFileClip.py @@ -87,7 +87,6 @@ def coreader(self): def close(self): """ Close the internal reader. """ if self.reader: - self.reader.close_proc() self.reader = None def __del__(self): From 8670b4b8ee25aed7e7a979c7d5a0aad50d4f7e9f Mon Sep 17 00:00:00 2001 From: jwg4 Date: Thu, 16 Jan 2020 01:39:39 +0000 Subject: [PATCH 3/8] Change the frame we look for. --- tests/test_VideoFileClip.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py index 00ae2bc83..bc8037e5d 100644 --- a/tests/test_VideoFileClip.py +++ b/tests/test_VideoFileClip.py @@ -50,7 +50,13 @@ def test_shallow_copy(): video = VideoFileClip(video_file) video_copy = video.set_start(1) del(video_copy) - video.audio.make_frame(2) + # 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__': From 78e46142092fbf375ca05141757fb7bc3eba054b Mon Sep 17 00:00:00 2001 From: Jack Grahl Date: Wed, 29 Jan 2020 00:02:18 +0000 Subject: [PATCH 4/8] We need a longer clip for the test to work correctly. --- tests/test_VideoFileClip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py index bc8037e5d..a4f767ddf 100644 --- a/tests/test_VideoFileClip.py +++ b/tests/test_VideoFileClip.py @@ -46,7 +46,7 @@ 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_432_433.webm' + video_file = 'media/big_buck_bunny_0_30.webm' video = VideoFileClip(video_file) video_copy = video.set_start(1) del(video_copy) From f25bc993f821cb5e346da30074f8066815373348 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Fri, 1 May 2020 00:47:05 +0100 Subject: [PATCH 5/8] Update test_VideoFileClip.py --- tests/test_VideoFileClip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py index a4f767ddf..2f1a9d625 100644 --- a/tests/test_VideoFileClip.py +++ b/tests/test_VideoFileClip.py @@ -49,7 +49,7 @@ def test_shallow_copy(): video_file = 'media/big_buck_bunny_0_30.webm' video = VideoFileClip(video_file) video_copy = video.set_start(1) - del(video_copy) + 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 From f88770a9f4c68d62c8f368ee280209dd0ebb2a58 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Fri, 1 May 2020 01:21:14 +0100 Subject: [PATCH 6/8] Temp readd line to check appveyor --- moviepy/audio/io/AudioFileClip.py | 1 + 1 file changed, 1 insertion(+) diff --git a/moviepy/audio/io/AudioFileClip.py b/moviepy/audio/io/AudioFileClip.py index 09eca0404..4ef935856 100644 --- a/moviepy/audio/io/AudioFileClip.py +++ b/moviepy/audio/io/AudioFileClip.py @@ -90,4 +90,5 @@ def close(self): self.reader = None def __del__(self): + self.reader.close_proc() self.close() From 214cb8463c30c747040b94707728fb289afcbc20 Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Fri, 1 May 2020 01:31:41 +0100 Subject: [PATCH 7/8] Re-fix --- moviepy/audio/io/AudioFileClip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moviepy/audio/io/AudioFileClip.py b/moviepy/audio/io/AudioFileClip.py index 4ef935856..8ab3ad81b 100644 --- a/moviepy/audio/io/AudioFileClip.py +++ b/moviepy/audio/io/AudioFileClip.py @@ -87,8 +87,8 @@ def coreader(self): def close(self): """ Close the internal reader. """ if self.reader: + self.reader.close_proc() self.reader = None def __del__(self): - self.reader.close_proc() self.close() From 08d20c0adf7c4d19f4d470e7669d0ab761697c3e Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Fri, 1 May 2020 01:48:29 +0100 Subject: [PATCH 8/8] Final back-to-where-it-was --- moviepy/audio/io/AudioFileClip.py | 1 - 1 file changed, 1 deletion(-) diff --git a/moviepy/audio/io/AudioFileClip.py b/moviepy/audio/io/AudioFileClip.py index 8ab3ad81b..09eca0404 100644 --- a/moviepy/audio/io/AudioFileClip.py +++ b/moviepy/audio/io/AudioFileClip.py @@ -87,7 +87,6 @@ def coreader(self): def close(self): """ Close the internal reader. """ if self.reader: - self.reader.close_proc() self.reader = None def __del__(self):