MoviePy file creation results in Broken Pipe

Hey guys,

Apologies if this has been answered elsewhere…

I have a Flask app with MoviePy that can render video files with ffmpeg no problem locally. On Render, it dies after a few seconds with a broken pipe. I’m using moviepy==1.0.3 and Python 3.10

I created this file to test it and run from the shell, with the same result:

import os
from moviepy.editor import *

directory = 'jobs/31/images/'
for filename in os.listdir(directory):
    f = os.path.join(directory, filename)
    if os.path.isfile(f):
        file_name, file_extension = os.path.splitext(f)
        if file_extension == '.png':
            print("Added "+str(f))
if len(ic)>0:
    video = concatenate(ic, method="compose")
    video.write_videofile('static/test.mp4', fps=24)

The error log:

render@srv-***-64n9v:~/project/src$ python 
Added jobs/31/images/img-4.png
Added jobs/31/images/img-2.png
Added jobs/31/images/img-1.png
Added jobs/31/images/img-0.png
Added jobs/31/images/img-3.png
Moviepy - Building video static/test.mp4.
Moviepy - Writing video static/test.mp4

t:  23%|█████████████████▋                                                          | 56/240 [00:03<00:22,  8.23it/s, now=None]Traceback (most recent call last):
  File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/video/io/", line 136, in write_frame
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/render/project/src/", line 17, in <module>
    video.write_videofile('static/test.mp4', fps=24)
  File "<decorator-gen-55>", line 2, in write_videofile
  File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-54>", line 2, in write_videofile
  File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/", line 135, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-53>", line 2, in write_videofile
  File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/video/", line 300, in write_videofile
    ffmpeg_write_video(self, filename, fps, codec,
  File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/video/io/", line 228, in ffmpeg_write_video
  File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/video/io/", line 180, in write_frame
    raise IOError(error)
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file static/test.mp4:


Can anyone suggest what the problem might be and how to fix it?



I see my colleague has picked up the ticket you also opened, let’s keep the conversation in one place (on the ticket). Then you can update the post when we get to the bottom of your issue.

Unless another community member swoops in with a solution :slight_smile:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.