This topic was automatically generated from Slack. You can find the original thread here.
Getting same error again and again for no specific reason.
the code:
# pipedream add-package moviepy==2.0.0.dev2
**import** os
**from** moviepy.editor **import** concatenate_videoclips, ImageClip, AudioFileClip
**from** PIL **import** Image
**import** numpy **as** np
**def** create_video(memes_dir, audio_path, output_path):
clips = []
**for** filename **in** os.listdir(memes_dir):
img_path = os.path.join(memes_dir, filename)
img = Image.**open**(img_path)
**if** img:
x, y = img.size
desired_w, desired_h = 1080, 1920
new_x = desired_w
new_y = **int**(y ** desired_w / x)
img = img.resize((new_x, new_y), resample=Image.LANCZOS)
new_im = Image.new('RGB', (desired_w, desired_h), (0, 0, 0))
paste_x = (desired_w - new_x) // 2
paste_y = (desired_h - new_y) // 2
new_im.paste(img, (paste_x, paste_y))
clips.append(ImageClip(np.array(new_im)).set_duration(6))
`concat_clip = concatenate_videoclips(clips, method="compose")`
`audio_clip = AudioFileClip(audio_path)`
`final_clip = concat_clip.set_audio(audio_clip)`
`final_clip.write_videofile(output_path, fps=24, temp_audiofile_path="/tmp")`
`**return** output_path`
**def** handler(pd: 'pipedream'):
memes_dir = "/tmp/memes"
audio_path = "/tmp/audio.mp3"
output_path = "/tmp/output.mp4"
**return* create_video(memes_dir, audio_path, output_path)