Can I save a matplotlib animation to webm format?

拈花ヽ惹草 提交于 2019-12-12 04:06:23

问题


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:


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):
    [...]


来源:https://stackoverflow.com/questions/46300010/can-i-save-a-matplotlib-animation-to-webm-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!