我可以将 matplotlib 动画保存为 webm 格式吗?

Can I save a matplotlib animation to webm format?

我将此示例代码用作测试用例:https://matplotlib.org/examples/animation/moviewriter.html

在这段代码中,他们使用 FFMPEG 将 matplotlib 动画写入 .mp4 视频文件。是否可以写入 .webm 格式?

但我不确定该怎么做。

确保你有 ffmpeg compiledlibvpx (运行 ffmpeg 没有参数,看看是否有 --enable-libvpx输出)。

FFMpegWriter = manimation.writers['ffmpeg']
writer = FFMpegWriter(fps=15, codec='libvpx-vp9') # or libvpx-vp8

[...]

with writer.saving(fig, "writer_test.webm", 100):
    [...]