moviepy icon indicating copy to clipboard operation
moviepy copied to clipboard

CompositeAudioClip close() method doesn't close opened handles

Open busbaby opened this issue 1 year ago • 0 comments

Expected Behavior

CompositeAudioClip close() method should close any/all opened handles owned by self.

Actual Behavior

Calling close() on CompositeAudioClip object leaves opened handles.

Steps to Reproduce the Problem

from moviepy.audio.AudioClip import CompositeAudioClip
from moviepy.audio.io.AudioFileClip import AudioFileClip
import sys
import shutil
import uuid
import os

# Usage: python foo.py sample.wav
# https://download.samplelib.com/wav/sample-9s.wav <-- sample file if needed
fileName = sys.argv[1]
dirName = uuid.uuid4().hex
copyNames = [os.path.join(dirName, f"{x}.wav") for x in list("abc")]
# Copy sample.wav into temp directory as a.wav, b.wav, c.wav
os.makedirs(dirName, exist_ok=True)
[shutil.copy(fileName, x) for x in copyNames]
# Create CompositeAudioClip from files in temp directory
audioClip = CompositeAudioClip([AudioFileClip(x) for x in copyNames])
# Close CompositeAudioClip expected to close any opened handles
audioClip.close()
# Unable to delete files since audioClips has opened handles
shutil.rmtree(dirName)

Specifications

  • Python Version: 3.11.5
  • MoviePy Version: 1.0.3
  • Platform Name: Windows
  • Platform Version: 10 Pro

busbaby avatar Sep 30 '23 01:09 busbaby