我可以将matplotlib动画保存为webm格式吗? [英] Can I save a matplotlib animation to webm format?
本文介绍了我可以将matplotlib动画保存为webm格式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此示例代码作为测试用例: https://matplotlib.org/ examples / animation / moviewriter.html
I am using this example code as a test case: https://matplotlib.org/examples/animation/moviewriter.html
在此代码中,他们使用FFMPEG将matplotlib动画写入.mp4视频文件。可以写成.webm格式吗?
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.
推荐答案
确保您拥有 ffmpeg
使用 libvpx
编译(不带参数运行 ffmpeg
,看看是否有一个-在输出中启用libvpx
)。
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):
[...]
这篇关于我可以将matplotlib动画保存为webm格式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文