我正在尝试使用此处的示例使用 matplotlib 制作动画。起初的问题是 ffmpeg 没有安装,所以我从 macports 安装了它——但并不是说不支持“rgba”。错误信息:
File "Plot_shocktube1D.py", line 85, in <module>
animDensity.save(densityAnimationName, extra_args=['-vcodec', 'libx264']) #, writer=movWriter)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 615, in save
writer.grab_frame()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 199, in grab_frame
dpi=self.dpi)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 1363, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2012, in print_figure
print_method = self._get_print_method(format)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1953, in _get_print_method
'%s.' % (format, ', '.join(formats)))
ValueError: Format "rgba" is not supported.
Supported formats: bmp, emf, eps, gif, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff.
现在,经过一番努力,我设置了一个FFMpegWriter
usingpng
而不是rgba
,但现在我遇到了新错误......
movWriter = anim.FFMpegWriter(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None)
movWriter.frame_format = 'jpg'
animDensity = anim.FuncAnimation(fig, animateDensity, frames=10, interval=100, blit=True)
animDensity.save(densityAnimationName, extra_args=['-vcodec', 'libx264'], writer=movWriter)
有错误:
File "Plot_shocktube1D.py", line 85, in <module>
animDensity.save(densityAnimationName, extra_args=['-vcodec', 'libx264'], writer=movWriter)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 615, in save
writer.grab_frame()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 199, in grab_frame
dpi=self.dpi)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 1363, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2093, in print_figure
**kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 326, in print_jpg
self._print_bitmap(filename, *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 319, in _print_bitmap
self.write_bitmap(filename, width, height, dpi)
ValueError: Unknown file type
我的印象是我只是没有安装我需要的东西......通常macports为我设置了所有东西,我不确定在哪里看。任何帮助将不胜感激。