python - 导出动画 ffmpeg 时出错 - Matplotlib

标签 python matplotlib animation ffmpeg

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

RuntimeError: Requested MovieWriter (ffmpeg) not available
查看其他问题,主要选项是安装ffmpeg通过 conda :
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不可用。

最佳答案

您想使用 Homebrew 安装 FFmpeg 及其依赖项。 Homebrew 用于安装 macOS 上未预装的软件包。它将软件包安装到它们自己的目录中,并将文件符号链接(symbolic link)到/usr/local,从而为您节省了指定路径的麻烦。
您可以安装Homebrew通过在 macOS 终端上粘贴以下命令。

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 
安装成功后,您可以按如下方式安装FFmpeg:
brew install ffmpeg

关于python - 导出动画 ffmpeg 时出错 - Matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64364319/

相关文章:

python - 使用 Matplotlib 和 iPython,如何将 x 和 y 轴限制重置为自动缩放?

python - yticks 的字体大小出乎意料地可变

javascript - jQuery动画向左滑动​​没有文字换行

html - 图像的无限横向滚动动画

python - 如何通过nltk在Python中将Tree类型转换为String类型?

python - 适用于 OSX 10.6 上 PyQt 的 Qt 设计器

python - 将张量添加到 Tensorflow 中张量的特定列

python - django-mptt 在标准 ModelAdmin 中嵌套下拉菜单?

python - 如何在seaborn catplot中旋转xticklabels

Python Matplotlib : Centering figure around a moving artist