Can I save a matplotlib animation to webm format?

2019-08-17 14:19发布

I am using this example code as a test case: https://matplotlib.org/examples/animation/moviewriter.html

In this code, they use FFMPEG to write the matplotlib animation to an .mp4 video file. Is it possible to write to a .webm format?

But I am not sure how to go about doing this.

1条回答
何必那么认真
2楼-- · 2019-08-17 14:47

Make sure you have ffmpeg compiled with libvpx (run ffmpeg with no arguments and see if there's a --enable-libvpx in the output).

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

[...]

with writer.saving(fig, "writer_test.webm", 100):
    [...]
查看更多
登录 后发表回答