From: Tony Yu <ts...@gm...> - 2012-04-07 17:34:19
|
I've been using the animations subpackage since it was introduced, but I only recently tried to save an animation using the `save` method. Unfortnately, I get a RuntimeError whenever I try to use it: ... File "/Users/Tony/python/devel/mpl/lib/matplotlib/backends/backend_agg.py", line 4 52, in print_raw renderer._renderer.write_rgba(filename_or_obj) RuntimeError: Error writing to file This can be reproduced with any animation example, e.g. simple_anim.py<http://matplotlib.sourceforge.net/examples/animation/simple_anim.html>, by replacing `plt.show()` with `ani.save('simple_anim.avi')`. The actual error is from a shell call to ffmpeg, which roughly boils down to: #~~~~ import subprocess import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([0, 1]) command = ['ffmpeg', '-f', 'rawvideo', '-vcodec', 'rawvideo', '-s', '800x600', '-pix_fmt', 'rgba', '-r', '5.0', '-i', 'pipe:', '-vcodec', 'mpeg4', '-y', 'test.avi'] proc= subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE) fileobj = proc.stdin fig.savefig(fileobj, format='rgba', dpi=100) #~~~~ (I just copied the ffmpeg command from an example run, so the option values may vary on other systems.) The error here is the same, and, unfortunately, not very informative. Is this saving functionality platform dependent? (I'm on osx.) Thanks, -Tony |