Hi,
while trying out animation.ArtistAnimation, my script would not
terminate. The .mp4 file was generated and later found out that the
script would block at proc.wait() within _make_movie. ffmpeg
generates quite a bit of text and it seems that if stdout/stderr are
not closed, wait() does not return (this is on Windows). I have made
some modifications to animation.py to get it to work, but can't tell
how this will behave on other platforms.
Proposed change in matplotlib/animation.py:
def \_make\_movie\(self, fname, fps, codec, frame\_prefix, cmd\_gen=None\):
\# Uses subprocess to call the program for assembling frames into a
\# movie file\. \*cmd\_gen\* is a callable that generates the sequence
\# of command line arguments from a few configuration options\.
from subprocess import Popen, PIPE
if cmd\_gen is None:
cmd\_gen = self\.ffmpeg\_cmd
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.stdout.close()
+ proc.stderr.close()
proc.wait()
This was tested to work with the configuration below.
OS: Windows 7
Python Version: Python 2.7.2 |EPD 7.2-1 (32-bit)| (default, Sep 14
2011, 11:02:05) [MSC v.1500 32 bit (Intel)]
Matplotlib version: 1.1.0
ffmpeg version N-38622-g1eabd71
Best regards
Thanks for the report. The code to write movie files has been
refactored substantially to improve a wide variety of problems. One
changes has been to use communicate() instead of wait(), both to get
stdout and stderr text, but also to fix a similar problem on linux.
Can you try replacing the close() and wait() calls with just a single
call to communicate() and see if that also fixes your problem?
Thanks,
Ryan
ยทยทยท
On Tue, Mar 13, 2012 at 10:43 PM, Stephane Gagnon <stephane.f.gagnon@...149...> wrote:
while trying out animation.ArtistAnimation, my script would not
terminate. The .mp4 file was generated and later found out that the
script would block at proc.wait() within _make_movie. ffmpeg
generates quite a bit of text and it seems that if stdout/stderr are
not closed, wait() does not return (this is on Windows). I have made
some modifications to animation.py to get it to work, but can't tell
how this will behave on other platforms.
Proposed change in matplotlib/animation.py:
def \_make\_movie\(self, fname, fps, codec, frame\_prefix, cmd\_gen=None\):
\# Uses subprocess to call the program for assembling frames into a
\# movie file\. \*cmd\_gen\* is a callable that generates the sequence
\# of command line arguments from a few configuration options\.
from subprocess import Popen, PIPE
if cmd\_gen is None:
cmd\_gen = self\.ffmpeg\_cmd
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.stdout.close()
+ proc.stderr.close()
proc.wait()
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma