Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Animation verbose #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/animation/double_pendulum_animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ def animate(i):
ani = animation.FuncAnimation(fig, animate, np.arange(1, len(y)),
interval=25, blit=True, init_func=init)

#ani.save('double_pendulum.mp4', fps=15, clear_temp=False)
#ani.save('double_pendulum.mp4', fps=15, clear_temp=True)
plt.show()
7 changes: 6 additions & 1 deletion lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# * Need to consider event sources to allow clicking through multiple figures
import itertools
from matplotlib.cbook import iterable
from matplotlib import verbose

class Animation(object):
'''
Expand Down Expand Up @@ -120,13 +121,15 @@ def save(self, filename, fps=5, codec='mpeg4', clear_temp=True,
self._draw_next_frame(data, blit=False)
fname = '%s%04d.png' % (frame_prefix, idx)
fnames.append(fname)
verbose.report('Animation.save: saved frame %d to fname=%s'%(idx, fname), level='debug')
self._fig.savefig(fname)

self._make_movie(filename, fps, codec, frame_prefix)

#Delete temporary files
if clear_temp:
import os
verbose.report('Animation.save: clearing temporary fnames=%s'%str(fnames), level='debug')
for fname in fnames:
os.remove(fname)

Expand Down Expand Up @@ -155,7 +158,9 @@ def _make_movie(self, fname, fps, codec, frame_prefix, cmd_gen=None):
from subprocess import Popen, PIPE
if cmd_gen is None:
cmd_gen = self.ffmpeg_cmd
proc = Popen(cmd_gen(fname, fps, codec, frame_prefix), shell=False,
command = cmd_gen(fname, fps, codec, frame_prefix)
verbose.report('Animation._make_movie running command: %s'%' '.join(command))
proc = Popen(command, shell=False,
stdout=PIPE, stderr=PIPE)
proc.wait()

Expand Down