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:
movie_test.py
import os
from moviepy.editor import *
ic=[]
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))
ic.append(ImageClip(f).set_duration(2))
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 movie_test.py
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
Generating...
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/ffmpeg_writer.py", line 136, in write_frame
self.proc.stdin.write(img_array.tobytes())
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/render/project/src/movie_test.py", 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/decorators.py", 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/decorators.py", 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/decorators.py", 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/VideoClip.py", 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/ffmpeg_writer.py", line 228, in ffmpeg_write_video
writer.write_frame(frame)
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_writer.py", 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:
b''
Can anyone suggest what the problem might be and how to fix it?
Cheers