Matplotlib中的像素化动画

osn*_*noz 9 python animation matplotlib scipy

我一直在使用Matplotlib的动画设备来制作动画人物.我注意到一个问题,对于具有大量帧的动画尤其明显,这是因为数字的质量很快恶化,导致像素化 - 模糊的输出.

例子:

凌乱的网格线 凌乱的网格线

像素化输出 像素化输出

我一直在使用动画渲染

import matplotlib
matplotlib.use("Agg")

anim = animation.FuncAnimation(fig, ..., blit=False)
mywriter = animation.FFMpegWriter(fps=15)
anim.save("path.mp4", writer=mywriter)
Run Code Online (Sandbox Code Playgroud)

我尝试过使用blit = True/False,但没有发现太大的区别.

Matplotlib版本:1.4.2.系统:Mac 10.10

mrc*_*rcl 5

这对我有用.

您可以在创建编写器实例时更改比特率

import matplotlib.animation as animation

anim = animation.FuncAnimation(fig, ...)

FFMpegWriter = animation.writers['ffmpeg']
metadata = dict(title='Movie Test', artist='Matplotlib',
                comment='Movie support!')

# Change the video bitrate as you like and add some metadata.
writer = FFMpegWriter(fps=15, bitrate=1000, metadata=metadata)
Run Code Online (Sandbox Code Playgroud)

然后,您可以保存您的视频.

anim.save("path.mp4", writer=mywriter)
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你