X Tutup
Skip to content

save animation to mp4 fail  #8053

@angelleng

Description

@angelleng

To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.

Bug report

Bug summary

  • A short 1-2 sentences that succinctly describes the bug
    I was trying to save an matplotlib.animation.ArtistAnimation object to mp4. but it failed and returned error: ValueError: I/O operation on closed file

Code for reproduction

  • A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required
# Paste your code here
ims = [] 
for i in range(5): 
       im1, = plt.plot(x[:,0], x[:,1], 'b.')
        im2, = plt.plot(fakenp[:,0], fakenp[:,1], 'rx')
        ims.append([im1, im2])
ani = animation.ArtistAnimation(fig, ims, interval=100, blit=True,
    repeat_delay=1000) 
ani.save('sample.mp4', writer='ffmpeg')

Actual outcome

  • The output produced by the above code, which may be a screenshot, console output, etc.
# If applicable, paste the console output here
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/matplotlib/animation.py", line 1013, in save
    writer.grab_frame(**savefig_kwargs)
  File "/home/jingleng/envs/my_root/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/matplotlib/animation.py", line 256, in saving
    self.finish()
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/matplotlib/animation.py", line 276, in finish
    self.cleanup()
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/matplotlib/animation.py", line 311, in cleanup
    out, err = self._proc.communicate()
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/subprocess32.py", line 927, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/subprocess32.py", line 1713, in _communicate
    orig_timeout)
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/subprocess32.py", line 1769, in _communicate_with_poll
    register_and_append(self.stdout, select_POLLIN_POLLPRI)
  File "/home/jingleng/envs/my_root/lib/python2.7/site-packages/subprocess32.py", line 1748, in register_and_append
    poller.register(file_obj.fileno(), eventmask)
ValueError: I/O operation on closed file

Expected outcome

it saves the animation to video file 'sample.mp4'.

Matplotlib version

  • using matplotlib 2.0.0, Python 2.7.13 :: Anaconda 2.1.0 (64-bit), on OSX.
  • installed both python and matplotlib through anaconda.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup