moviepy icon indicating copy to clipboard operation
moviepy copied to clipboard

write_frame raise IOError(error) OSError: [Errno 32] Broken pipe

Open vinayinfo opened this issue 5 years ago • 10 comments

        audio = AudioFileClip(audio_path)
        duration = audio.duration
        image = ImageClip(image).set_duration(duration)
        image = image.set_audio(audio)
        image.write_videofile(video_file_name, fps=25, remove_temp=True)

Actual Behavior

Moviepy - Building video /tmp/new-20200129050549.mp4.
MoviePy - Writing audio in new-20200129050549TEMP_MPY_wvf_snd.mp3
MoviePy - Done.
Moviepy - Writing video /tmp/new-20200129050549.mp4

t:   7%|▋         | 47/645 [00:01<00:46, 12.94it/s, now=None]Internal Server Error: /generate_video/
Traceback (most recent call last):
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 133, 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 "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-51>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-50>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-49>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/code/moviepy/moviepy/video/VideoClip.py", line 326, in write_videofile
    logger=logger)
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 223, in ffmpeg_write_video
    writer.write_frame(frame)
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 177, in write_frame
    raise IOError(error)
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file /tmp/new-20200129050549.mp4:

Specifications

  • Python Version: 3.7
  • Moviepy Version: 1.0.1
  • Platform Name: docker
  • Platform Version:

vinayinfo avatar Jan 29 '20 05:01 vinayinfo

Getting error, while creating video, duration more then 45 second

Traceback (most recent call last):
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 133, in write_frame
    self.proc.stdin.write(img_array.tobytes())
BrokenPipeError: [Errno 32] Broken pipe``` 

vinayinfo avatar Jan 29 '20 06:01 vinayinfo

I think that you are missing the last line(s) of your error trace. Or maybe MoviePy's error reporting also crashed.

tburrows13 avatar Feb 24 '20 03:02 tburrows13

  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 133, 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 "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/code/apps/texttospeech/views.py", line 74, in get
    tts.save_video_file()
  File "/code/apps/texttospeech/models.py", line 51, in save_video_file
    new_video = self.get_movie_obj.convert_image_2_video()
  File "/code/apps/texttospeech/utils.py", line 128, in convert_image_2_video
    image.write_videofile(self.new_video, fps=25, remove_temp=True, threads=5)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-51>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-50>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-49>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/code/moviepy/moviepy/video/VideoClip.py", line 326, in write_videofile
    logger=logger)
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 223, in ffmpeg_write_video
    writer.write_frame(frame)
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 177, in write_frame
    raise IOError(error)
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file /tmp/new-20200221052541.mp4:

 b''

vinayinfo avatar Feb 24 '20 05:02 vinayinfo

Thanks for reporting the bug, unfortunately its not a very helpful error message!

tburrows13 avatar Feb 24 '20 05:02 tburrows13

After using docker configuration I am getting below error.

chunk:  32%|███▏      | 101/311 [00:03<00:03, 64.26it/s, now=None]Internal Server Error: /generated_sutitle_add_to_video/
Traceback (most recent call last)::00<00:00, 288.38it/s, now=None]
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/code/apps/texttospeech/views.py", line 96, in get
    tts.add_sub_title_to_video()
  File "/code/apps/texttospeech/models.py", line 62, in add_sub_title_to_video
    new_video = self.get_movie_obj.add_subtitle_to_video()
  File "/code/apps/texttospeech/utils.py", line 136, in add_subtitle_to_video
    result.write_videofile(self.new_sub_video, fps=clip.fps, remove_temp=True, threads=5)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-55>", line 2, in write_videofile
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-54>", line 2, in write_videofile
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-53>", line 2, in write_videofile
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/video/VideoClip.py", line 317, in write_videofile
    logger=logger)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-45>", line 2, in write_audiofile
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/AudioClip.py", line 210, in write_audiofile
    logger=logger)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-9>", line 2, in ffmpeg_audiowrite
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/io/ffmpeg_audiowriter.py", line 169, in ffmpeg_audiowrite
    logger=logger):
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/AudioClip.py", line 86, in iter_chunks
    fps=fps, buffersize=chunksize)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-44>", line 2, in to_soundarray
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/AudioClip.py", line 127, in to_soundarray
    snd_array = self.get_frame(tt)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-11>", line 2, in get_frame
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/Clip.py", line 93, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/AudioClip.py", line 297, in make_frame
    for c, part in zip(self.clips, played_parts)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/AudioClip.py", line 298, in <listcomp>
    if (part is not False)]
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-11>", line 2, in get_frame
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/Clip.py", line 93, in get_frame
    return self.make_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/io/AudioFileClip.py", line 77, in <lambda>
    self.make_frame = lambda t: self.reader.get_frame(t)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/io/readers.py", line 185, in get_frame
    self.buffer_around(fr_max)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/io/readers.py", line 239, in buffer_around
    array = self.read_chunk(chunksize)
  File "/usr/local/lib/python3.7/site-packages/moviepy-1.0.1-py3.7.egg/moviepy/audio/io/readers.py", line 113, in read_chunk
    s = self.proc.stdout.read(L)
AttributeError: 'NoneType' object has no attribute 'stdout'``` 

vinayinfo avatar Feb 24 '20 09:02 vinayinfo

  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 133, 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 "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/code/apps/texttospeech/views.py", line 74, in get
    tts.save_video_file()
  File "/code/apps/texttospeech/models.py", line 51, in save_video_file
    new_video = self.get_movie_obj.convert_image_2_video()
  File "/code/apps/texttospeech/utils.py", line 128, in convert_image_2_video
    image.write_videofile(self.new_video, fps=25, remove_temp=True, threads=5)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-51>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-50>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "</usr/local/lib/python3.7/site-packages/decorator.py:decorator-gen-49>", line 2, in write_videofile
  File "/code/moviepy/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "/code/moviepy/moviepy/video/VideoClip.py", line 326, in write_videofile
    logger=logger)
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 223, in ffmpeg_write_video
    writer.write_frame(frame)
  File "/code/moviepy/moviepy/video/io/ffmpeg_writer.py", line 177, in write_frame
    raise IOError(error)
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file /tmp/new-20200221052541.mp4:

 b''

getting same thing.

Is there a spot where I can print out what's going into the ffmpeg_writer? My print statements in general aren't popping out in the terminal/cmd.

rmasiso avatar Jun 06 '20 01:06 rmasiso

I'm facing the same error while writing a video file inside aws lambda, few days back the same error occurred when i try to write a video file inside ec2 instance but i resolved that error by increasing the memory of my instance.

[ERROR] OSError: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file b8e608e489744756a98a39f8b49d56e0-677299_AMTEMP_MPY_wvf_snd.mp3: b'b8e608e489744756a98a39f8b49d56e0-677299_AMTEMP_MPY_wvf_snd.mp3: Read-only file system\n' In case it helps, make sure you are using a recent version of FFMPEG (the versions in the Ubuntu/Debian repos are deprecated). Traceback (most recent call last): File "/var/task/lambda_function.py", line 43, in lambda_handler clip.write_videofile('/tmp/'+'zain'+local_file_name) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 135, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) File "/var/task/moviepy/video/VideoClip.py", line 298, in write_videofile logger=logger) File "", line 2, in write_audiofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/AudioClip.py", line 210, in write_audiofile logger=logger) File "", line 2, in ffmpeg_audiowrite File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 170, in ffmpeg_audiowrite writer.write_frames(chunk) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 117, in write_frames raise IOError(error)

zainraj50 avatar Dec 10 '21 22:12 zainraj50

I'm facing the same error while writing a video file inside aws lambda, few days back the same error occurred when i try to write a video file inside ec2 instance but i resolved that error by increasing the memory of my instance.

[ERROR] OSError: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file b8e608e489744756a98a39f8b49d56e0-677299_AMTEMP_MPY_wvf_snd.mp3: b'b8e608e489744756a98a39f8b49d56e0-677299_AMTEMP_MPY_wvf_snd.mp3: Read-only file system\n' In case it helps, make sure you are using a recent version of FFMPEG (the versions in the Ubuntu/Debian repos are deprecated). Traceback (most recent call last): File "/var/task/lambda_function.py", line 43, in lambda_handler clip.write_videofile('/tmp/'+'zain'+local_file_name) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 135, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) File "/var/task/moviepy/video/VideoClip.py", line 298, in write_videofile logger=logger) File "", line 2, in write_audiofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/AudioClip.py", line 210, in write_audiofile logger=logger) File "", line 2, in ffmpeg_audiowrite File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 170, in ffmpeg_audiowrite writer.write_frames(chunk) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 117, in write_frames raise IOError(error)

Exact same issue for me. Any solutions here?

Luca-Blight avatar Aug 09 '22 14:08 Luca-Blight

I'm facing the same error while writing a video file inside aws lambda, few days back the same error occurred when i try to write a video file inside ec2 instance but i resolved that error by increasing the memory of my instance. [ERROR] OSError: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file b8e608e489744756a98a39f8b49d56e0-677299_AMTEMP_MPY_wvf_snd.mp3: b'b8e608e489744756a98a39f8b49d56e0-677299_AMTEMP_MPY_wvf_snd.mp3: Read-only file system\n' In case it helps, make sure you are using a recent version of FFMPEG (the versions in the Ubuntu/Debian repos are deprecated). Traceback (most recent call last): File "/var/task/lambda_function.py", line 43, in lambda_handler clip.write_videofile('/tmp/'+'zain'+local_file_name) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 135, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) File "", line 2, in write_videofile File "/var/task/moviepy/decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) File "/var/task/moviepy/video/VideoClip.py", line 298, in write_videofile logger=logger) File "", line 2, in write_audiofile File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/AudioClip.py", line 210, in write_audiofile logger=logger) File "", line 2, in ffmpeg_audiowrite File "/var/task/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 170, in ffmpeg_audiowrite writer.write_frames(chunk) File "/var/task/moviepy/audio/io/ffmpeg_audiowriter.py", line 117, in write_frames raise IOError(error)

Exact same issue for me. Any solutions here?

try to increase the hardware configuration (increasing ram and processing power of instance)

zainraj50 avatar Aug 10 '22 16:08 zainraj50

Found my problem and the solution for it.

I'm running my program in a lambda function and it was attempting to write the audiofile to the current working directory /var/task/ instead of /tmp(ephemeral storage). The temp_audiofile path was not set at the time, only the filename.

For a lambda function, you can only write to /tmp, thus the argument for both filename and temp_audiofile should have a /tmp prefix. Perhaps not necessary for the temp_audiofile if the audio parameter is set to "false".

Here's my line:

resized_video.write_videofile( filename=resized_path, codec="libx264", temp_audiofile='/tmp/temp-audio.m4a', bitrate="1500k", remove_temp=True, audio_codec="aac")

Luca-Blight avatar Aug 10 '22 17:08 Luca-Blight

I have the same issue while running on lambda function. My temporary files (audio, image and video) are all prefix with /tmp/ . I have also increase my memory of the lambda function. Any advice for me? I have the error while running

video.write_videofile(video_file, fps=15)

ERROR] OSError: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file af694dbc-ad3c-4b99-bae4-de221e748f35TEMP_MPY_wvf_snd.mp3: b'af694dbc-ad3c-4b99-bae4-de221e748f35TEMP_MPY_wvf_snd.mp3: Read-only file system\n' In case it helps, make sure you are using a recent version of FFMPEG (the versions in the Ubuntu/Debian repos are deprecated).

Ecupse avatar Feb 11 '23 09:02 Ecupse

same issue -

Moviepy - Building video /tmp/output/video.mp4. MoviePy - Writing audio in /tmp/output/temp-audio.mp3 MoviePy - Done. Moviepy - Writing video /tmp/output/video.mp4

t: 8%|████████████▏ | 48/624 [00:06<06:34, 1.46it/s, now=None]Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-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 "/srv/yt1/lambda_function.py", line 424, in lambda_handler("", "") File "/srv/yt1/lambda_function.py", line 422, in lambda_handler cm.CreateMP4(upload_to_yt) File "/srv/yt1/lambda_function.py", line 371, in CreateMP4 f1.write_videofile(file, fps = 24 , temp_audiofile=os.path.join(DIR_PATH_OUTPUT, 'temp-audio.mp3' )) File "", line 2, in write_videofile File "/usr/local/lib/python3.10/dist-packages/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "", line 2, in write_videofile File "/usr/local/lib/python3.10/dist-packages/moviepy/decorators.py", line 135, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) File "", line 2, in write_videofile File "/usr/local/lib/python3.10/dist-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) File "/usr/local/lib/python3.10/dist-packages/moviepy/video/VideoClip.py", line 300, in write_videofile ffmpeg_write_video(self, filename, fps, codec, File "/usr/local/lib/python3.10/dist-packages/moviepy/video/io/ffmpeg_writer.py", line 228, in ffmpeg_write_video writer.write_frame(frame) File "/usr/local/lib/python3.10/dist-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/output/video.mp4:

b''

saurabhchandrapatel avatar Apr 29 '23 16:04 saurabhchandrapatel

I had the same problem inside a docker container. I have a CPU limit for it, but ffmpeg probably tries to use all active CPUs for this process. So, I added threads argument and it fixed the problem.

clip.write_videofile(
    video_folder,
    audio_codec="aac",
    temp_audiofile="/tmp/temp-audio.m4a",
    threads=config.cpu_count,
)

egorborisow avatar May 09 '23 17:05 egorborisow