You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OSX下MoviePy调用FFmpeg报‘preset’选项未识别错误如何解决?

Fixing MoviePy FFmpeg Errors on OSX 10.11.6

Hey there, let's tackle those two errors you're seeing—they're linked to the same root cause, so we can fix them together.

What's Going Wrong?

The core issue is your FFmpeg 2.8.6 version is extremely outdated (it dates back to 2015). MoviePy relies on modern FFmpeg features, and the preset parameter it passes by default isn't supported or is recognized incorrectly in such an old build. The "Broken pipe" error is just a side effect: FFmpeg crashes when it hits the unrecognized preset option, causing the communication pipe between Python and FFmpeg to break.

Your Ubuntu 16.04 setup works because it likely has a newer FFmpeg version (or one patched to support the preset parameter properly).

Solutions

We have two solid paths to resolve this:

1. Upgrade FFmpeg (Recommended)

This is the best long-term fix, as it eliminates compatibility issues for all future video processing tasks. On OSX, use Homebrew:

  • First, uninstall the old FFmpeg version if it was installed via Homebrew:
    brew uninstall ffmpeg
    
  • Install the latest stable FFmpeg build:
    brew install ffmpeg
    
  • Verify the upgrade succeeded:
    ffmpeg -version
    

You should see a version number like 4.x or higher. Now re-run your Python code—both errors should disappear, and your MP4 file will generate as expected.

2. Modify MoviePy Code to Work With Old FFmpeg

If you can't upgrade FFmpeg (e.g., due to system constraints), tweak your write_videofile call to avoid using the unrecognized preset parameter:

yellow_output = 'test_videos_output/solidYellowleft.mp4'
clip1 = VideoFileClip("test_videos/solidYellowLeft.mp4")
yellow_clip = clip1.fl_image(process_image)
# Override default params for compatibility with old FFmpeg
yellow_clip.write_videofile(
    yellow_output,
    audio=False,
    codec='libx264',  # Explicitly specify H.264 codec
    preset=None,      # Disable the problematic preset flag
    ffmpeg_params=['-crf', '23']  # Set quality (23 is the standard default)
)

This tells MoviePy to skip passing the preset flag and uses basic FFmpeg parameters that your 2.8.6 build understands.

Quick Note

The typo in your error message (solidWwhiteright.mp4 instead of solidYellowleft.mp4) is probably just a copy-paste mistake, but double-check your output paths to avoid file-not-found issues later!

内容的提问来源于stack exchange,提问作者asabbah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:42:26