Broken pipe when writing video file with moviepy in azure

Lidia Moussaoui 0 Reputation points
2024-06-05T15:11:14.81+00:00

Hello,

I have a program that retrieves images (png) and audio files from Azure Blob Storage to merge them into a video, which is then written to a temporary file and saved back to Blob Storage. I'm coding in Python and here is the function I use from MoviePy:

final_clip.write_videofile(temp_file_name, fps=24, codec='libx264', audio_codec='mp3')

I have containerized my code, and the Docker image works perfectly on my machine. However, once deployed on Azure, I encounter this problem with writing the video:

Failed: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file /tmp/tmp81o22bka.mp4: b'' Traceback (most recent call last): File "/usr/local/lib/python3.8/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 "/home/site/wwwroot/function_app.py", line 102, in generate_simple_video image_clip.write_videofile(temp_file_name, fps=24) File "<decorator-gen-55>", line 2, in write_videofile File "/usr/local/lib/python3.8/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 "/usr/local/lib/python3.8/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 "/usr/local/lib/python3.8/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) File "/usr/local/lib/python3.8/site-packages/moviepy/video/VideoClip.py", line 300, in write_videofile ffmpeg_write_video(self, filename, fps, codec, File "/usr/local/lib/python3.8/site-packages/moviepy/video/io/ffmpeg_writer.py", line 228, in ffmpeg_write_video writer.write_frame(frame) File "/usr/local/lib/python3.8/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 /tmp/tmp81o22bka.mp4: b''

From my online research, everyone suggests that it’s a resource issue (lack of RAM and CPU). I increased these resources in the Azure Function App configuration, but I still face the same problem.

I took a step-by-step approach to check for compatibility issues with the MoviePy function. I created a small 30-second video without audio, and it worked. Then, I added more options such as more images, audio, etc., but it failed.

I suspected a timeout issue, but even with an execution time of one minute only, it still fails.

I am out of ideas to test and really need help.

Thank you in advance.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,471 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,538 questions
0 comments No comments
{count} votes