【问题标题】:Error exporting animation ffmpeg - Matplotlib导出动画 ffmpeg 时出错 - Matplotlib
【发布时间】:2021-01-29 12:13:55
【问题描述】:

我在 Mac 上通过 anaconda 使用 python 导出动画时遇到问题。我收到以下RuntimeError

RuntimeError: Requested MovieWriter (ffmpeg) not available

看其他问题,主要选项是通过conda安装ffmpeg

conda install -c conda-forge ffmpeg

或者指定路径:

plt.rcParams['animation.ffmpeg_path'] = '/usr/local/bin/ffmpeg'

第二个选项只返回相同的RuntimeError。第一个选项返回一个单独的错误:

BrokenPipeError: [Errno 32] Broken pipe


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/Users/person/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 1152, in save
writer.grab_frame(**savefig_kwargs)

  File "/Users/person/opt/anaconda3/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)

  File "/Users/person/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 232, in saving
self.finish()

  File "/Users/person/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 368, in finish
self.cleanup()

  File "/Users/person/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 411, in cleanup
raise subprocess.CalledProcessError(

CalledProcessError: Command '['ffmpeg', '-f', 'rawvideo', '-vcodec', 'rawvideo', '-s', '1600x1302', '-pix_fmt', 'rgba', '-r', '10', '-loglevel', 'error', '-i', 'pipe:', '-vcodec', 'h264', '-pix_fmt', 'yuv420p', '-b', '8000k', '-vcodec', 'libx264', '-y', 'test_text.mp4']' died with <Signals.SIGABRT: 6>.

追查这个错误然后让我回到卸载ffmpeg 包。但这只会导致初始错误,指出 ffmpeg 不可用。

【问题讨论】:

  • 你试过了吗:superuser.com/questions/624561/install-ffmpeg-on-os-x。您可能还想查看 cocalc.com。它提供了预装 ffmpeg 的在线 ubuntu 模拟器。您可以上传文件,对其进行各种操作,然后下载修改后的文件。
  • 谢谢。那是一场战斗。我现在已经安装了 brew 但必须在控制台中插入正确的路径,否则它会引发同样的错误。我不确定有多少人会觉得这个问题有用。如果您将评论格式化为答案,我会接受它

标签: python matplotlib animation ffmpeg


【解决方案1】:

您想使用 Homebrew 安装 FFmpeg 及其依赖项。 Homebrew 用于安装 macOS 上未预装的软件包。它将软件包安装到它们自己的目录并将文件符号链接到 /usr/local,从而为您节省了指定路径的麻烦。

您可以通过在 macOS 终端上粘贴以下命令来安装 Homebrew

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 

安装成功后,可以按如下方式安装FFmpeg:

brew install ffmpeg

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2018-03-24
  • 1970-01-01
  • 2018-12-31
  • 2018-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多