moviepy: write out not working

This is my code:

# Import everything needed to edit/save/watch video clips
from moviepy.editor import VideoFileClip
from IPython.display import HTML

new_clip_output = 'test_output.mp4'
test_clip = VideoFileClip("test.mp4")
new_clip = test_clip.fl_image(lambda x: cv2.cvtColor(x, cv2.COLOR_RGB2YUV)) #NOTE: this function expects color images!!
new_clip.write_videofile(new_clip_output, audio=False)

Error
OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file test_output.mp4:

 b"Unrecognized option 'preset'.\nError splitting the argument list: Option not found\n"


Full error details are here:
`[MoviePy] >>>> Building video test_output.mp4
[MoviePy] Writing video test_output.mp4
  0%|          | 0/251 [00:00<?, ?it/s]
---------------------------------------------------------------------------
BrokenPipeError                           Traceback (most recent call last)
~/Documents/python3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in write_frame(self, img_array)
    133             if PY3:
--> 134                self.proc.stdin.write(img_array.tobytes())
    135             else:

BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
<ipython-input-30-7a601a4eaaf5> in <module>()
----> 1 new_clip.write_videofile(new_clip_output, audio=False)

<decorator-gen-175> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/Documents/python3/lib/python3.6/site-packages/moviepy/decorators.py in requires_duration(f, clip, *a, **k)
     52         raise ValueError("Attribute 'duration' not set")
     53     else:
---> 54         return f(clip, *a, **k)
     55 
     56 

<decorator-gen-174> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/Documents/python3/lib/python3.6/site-packages/moviepy/decorators.py in use_clip_fps_by_default(f, clip, *a, **k)
    135              for (k,v) in k.items()}
    136 
--> 137     return f(clip, *new_a, **new_kw)

<decorator-gen-173> in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)

~/Documents/python3/lib/python3.6/site-packages/moviepy/decorators.py in convert_masks_to_RGB(f, clip, *a, **k)
     20     if clip.ismask:
     21         clip = clip.to_RGB()
---> 22     return f(clip, *a, **k)
     23 
     24 @decorator.decorator

~/Documents/python3/lib/python3.6/site-packages/moviepy/video/VideoClip.py in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, progress_bar)
    347                            verbose=verbose, threads=threads,
    348                            ffmpeg_params=ffmpeg_params,
--> 349                            progress_bar=progress_bar)
    350 
    351         if remove_temp and make_audio:

~/Documents/python3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in ffmpeg_write_video(clip, filename, fps, codec, bitrate, preset, withmask, write_logfile, audiofile, verbose, threads, ffmpeg_params, progress_bar)
    214             frame = np.dstack([frame,mask])
    215 
--> 216         writer.write_frame(frame)
    217 
    218     writer.close()

~/Documents/python3/lib/python3.6/site-packages/moviepy/video/io/ffmpeg_writer.py in write_frame(self, img_array)
    176 
    177 
--> 178             raise IOError(error)
    179 
    180     def close(self):

OSError: [Errno 32] Broken pipe

MoviePy error: FFMPEG encountered the following error while writing file test_output.mp4:

 b"Unrecognized option 'preset'.\nError splitting the argument list: Option not found\n"

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17

Most upvoted comments

Hi, I had the same problem. I resolved the problem by installing python package ffmpeg. conda install -c conda-forge ffmpeg Hope this would help 😃

I get this bug with ffmpeg 4.3 but not ffmpeg 4.2.2, so it seems that with the latest version of ffmpeg, this bug has reappeared.

I get this bug with ffmpeg 4.3 but not ffmpeg 4.2.2, so it seems that with the latest version of ffmpeg, this bug has reappeared.

Version 4.2.2 of ffmpeg solved my problem too. conda install -c conda-forge ffmpeg=4.2.2

I get this bug with ffmpeg 4.3 but not ffmpeg 4.2.2, so it seems that with the latest version of ffmpeg, this bug has reappeared.

I think this is the real answer. My problem is fixed by degrading ffmpeg version from 4.3 to 4.2.2. Thus I think there’s some bugs in version 4.3.