我在 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/