I am making a video in moviepy where I have several ImageClip "slides" with accompanying audio. All of the audio clips are generated at runtime and written to a file on the disk.
with open("audio_buffer.mp3", "wb") as tempFile:
tempFile.write(audio)
audio = AudioFileClip("audio_buffer.mp3")
clip = ImageClip("my_image.png")
clip = clip.set_audio(audio)
clips.append(clip)
The beginnings of the slides have the correct audio, but the end of all of the slides is mixed with the audio of the last slide.
I think this is because MoviePy doesn't load the entire audio file. According to the MoviePy documentation:
An audio clip read from a sound file, or an array. The whole file is not loaded in memory. Instead, only a portion is read and stored in memory. this portion includes frames before and after the last frames read, so that it is fast to read the sound backward and forward.
I could write the audio of each clip to a separate file, but I don't want to save all of the audio to the disk. Is there any way to make MoviePy load the entire audio file?