在 moviepy 中加载整个 AudioFileClip
Load entire AudioFileClip in moviepy
我正在用 moviepy 制作视频,其中有多个 ImageClip "slides" 以及伴随的音频。所有音频剪辑都在运行时生成并写入磁盘上的文件。
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)
幻灯片开头的音频正确,但所有幻灯片的结尾都与最后一张幻灯片的音频混在一起。
我认为这是因为 MoviePy 没有加载整个音频文件。根据 MoviePy 文档:
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.
我可以将每个剪辑的音频写入一个单独的文件,但我不想将所有音频保存到磁盘。有没有办法让 MoviePy 加载整个音频文件?
对于任何未来的用户,我将 buffersize 参数设置为 math.inf
我正在用 moviepy 制作视频,其中有多个 ImageClip "slides" 以及伴随的音频。所有音频剪辑都在运行时生成并写入磁盘上的文件。
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)
幻灯片开头的音频正确,但所有幻灯片的结尾都与最后一张幻灯片的音频混在一起。
我认为这是因为 MoviePy 没有加载整个音频文件。根据 MoviePy 文档:
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.
我可以将每个剪辑的音频写入一个单独的文件,但我不想将所有音频保存到磁盘。有没有办法让 MoviePy 加载整个音频文件?
对于任何未来的用户,我将 buffersize 参数设置为 math.inf