From: Benjamin R. <ben...@ou...> - 2012-04-08 00:40:49
|
On Sat, Apr 7, 2012 at 1:34 PM, Tony Yu <ts...@gm...> wrote: > 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 > > Tony, The animation saving feature has be completely rewritten by Ryan recently and is in master. Could you give that a try? Ben Root |