Closing Preview window causes traceback because of broken pipe
Author: jmansillaCreated Feb 14, 2025Updated Jul 14, 2026
Labelsbugvideo
This simple snippet evidences the problem
from moviepy import VideoFileClip
clip = VideoFileClip(movie_path)
clip.preview()
clip.close()While the video is been played, proceed to close the window.
Expected Behavior
Program closes silently
Actual Behavior
This traceback is printed
/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/imageio_ffmpeg/binaries/ffmpeg-macos-x86_64-v7.1 -i movie.mp4 -loglevel error -f image2pipe -vf scale=1280:720 -sws_flags bicubic -pix_fmt rgb24 -vcodec rawvideo -
Traceback (most recent call last):
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/moviepy/video/io/ffplay_previewer.py", line 59, in show_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 "/Users/jmansilla/.virtualenvs/myproject/bin/mycommand", line 6, in <module>
sys.exit(main())
^^^^^^
File "/Users/jmansilla/projects/repo/myproject/ui/cli.py", line 76, in main
play_movie(movie_path)
File "/Users/jmansilla/projects/repo/myproject/ui/cli.py", line 87, in play_movie
clip.preview()
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/moviepy/decorators.py", line 53, in requires_duration
return func(clip, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/moviepy/decorators.py", line 24, in convert_masks_to_RGB
return func(clip, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/moviepy/video/VideoClip.py", line 632, in preview
ffplay_preview_video(
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/moviepy/video/io/ffplay_previewer.py", line 126, in ffplay_preview_video
previewer.show_frame(frame)
File "/Users/jmansilla/.virtualenvs/myproject/lib/python3.12/site-packages/moviepy/video/io/ffplay_previewer.py", line 70, in show_frame
raise IOError(error)
OSError: [Errno 32] Broken pipe
MoviePy error: FFPLAY encountered the following error while previewing clip :
NoneSteps and code to Reproduce the Problem
nothing to add
Used medias
none
Specifications
- Python Version: 3.12
- MoviePy Version: 2.1.2
- Platform Name: macOs
Source: Zulko/moviepy