79591276

Date: 2025-04-24 18:44:04
Score: 0.5
Natty:
Report link

Reading and writing the same file in parallel is the culprit.

tempfilename = "temp.mp4" # define a temp filename first
with tqdm(total=frames, desc="Saving", unit="frame") as pbar:
    anim.save(tempfilename, fps=fps, progress_callback=lambda i, n: pbar.update(1))

# Add sound using MoviePy
video = VideoFileClip(tempfilename)
video.audio = CompositeAudioClip([AudioFileClip("sound.wav")])
video.write_videofile(filename)

remove(tempfilename) # needs: from os import remove
startfile(filename)
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: D G