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 |
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 |
From: Tony Yu <ts...@gm...> - 2012-04-08 14:13:23
|
On Sat, Apr 7, 2012 at 8:40 PM, Benjamin Root <ben...@ou...> wrote: > > > 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 > > Hey Ben, This is error is using the current master, actually. I think the previous implementation saved images and read them with ffmpeg (or some other utility) instead of piping directly to ffmpeg. -Tony (Ben: sorry for the duplicate emails. Forgot to "reply-all") |
From: Ryan M. <rm...@gm...> - 2012-04-10 14:28:48
|
On Sun, Apr 8, 2012 at 9:13 AM, Tony Yu <ts...@gm...> wrote: > > > On Sat, Apr 7, 2012 at 8:40 PM, Benjamin Root <ben...@ou...> wrote: >> >> >> >> 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 It shouldn't be OS-dependent. In fact, as I keep being told "OSX is practically unix!". (Sorry, I just get tired of being told that and then having simple unix functionality fail spectacularly. I'm better...I swear.) Would it be possible to try the mencoder support instead? (If it's possible to get that installed). Also, could you try the ffmpeg_file "backend" which uses the temp files? It will be helpful to try to narrow down whether the piping itself is making it angry or if something is wrong with ffmpeg. You should just be able to do: anim.save(..., writer='ffmpeg_file') or anim.save(..., writer='mencoder') Also, can you run any/all of them with --verbose-debug? That might help give a bit more error information. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma |