Matplotlib 动画 - 保存文件速度问题
我正在尝试使用 Python-Matplotlib
制作动画。
我参考了这个教程:
http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/
在第一个例子中,动画在我直接运行 Python 脚本时效果很好,不过为了能保存动画(用 anim.save command
),我必须添加 'writer=animation.FFMpegFileWriter()
' 作为参数。然而,现在保存下来的文件播放速度比原始文件慢得多。实际上,不管我在 FuncAnimation
对象中设置 'interval
' 为多少,视频的时长总是 40 秒。
有没有什么建议可以解决这个问题?
谢谢你的帮助 :)
2 个回答
0
你需要把想要的每秒帧数作为一个参数来指定:
anim.save('filename.mp4', fps=120, writer=animation.FFMpegFileWriter())
3
我之前也遇到过用FFMpeg保存时的类似问题。
对我有效的解决办法是修改
writer=animation.FFMpegFileWriter()
改成
writer=animation.FFMpegFileWriter(fps=n)
这里的n是你想要的每秒输出帧数。