question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
        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:

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

2reactions
Luca-Blightcommented, Aug 10, 2022

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”)

2reactions
zainraj50commented, Dec 10, 2021

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 “<decorator-gen-55>”, line 2, in write_videofile File “/var/task/moviepy/decorators.py”, line 54, in requires_duration return f(clip, *a, **k) File “<decorator-gen-54>”, 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 “<decorator-gen-53>”, 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 “<decorator-gen-45>”, 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 “<decorator-gen-9>”, 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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Video save error · Issue #4 · wyhsirius/g3an-project - GitHub
When I ran demo_random.py using the pre-trained model g3an.pth in accordance with the ... raise IOError(msg) OSError: [Errno 32] Broken pipe.
Read more >
BrokenPipeError: [Errno 32] Broken pipe, imageio_ffmpeg ...
When i test it using flask-ngrok it works. But after deployment on flask using WSGI and apache2 server, it gives me this Broken...
Read more >
ffmpeg writer - OSError: [Errno 32] Broken pipe
I'm getting an extremely strange error when running convert on my video. After about 2% conversion the program will crash with:.
Read more >
“[Errno 32] Broken pipe” in Python - LinuxPip
"Broken pipe" is essentially an IOError error (short for input/output error), which happened at the Linux system level. It usually occurs when ...
Read more >
PYTHON : IOError: [Errno 32] Broken pipe when piping: `prog.py
PYTHON : IOError : [ Errno 32 ] Broken pipe when piping: `prog.py | othercmd` [ Gift : Animated Search Engine ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found