Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't close the audio reader which might be linked from a shallow copy. #1059

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion moviepy/audio/io/AudioFileClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 17 additions & 0 deletions tests/test_VideoFileClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ 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_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()