bzm3r
bzm3r

Reputation: 4615

matplotlib.animation: script works under Windows, and works under Linux for short animations, but hangs indefinitely for longer animations?

Here is the relevant code snippet:

ani = animation.FuncAnimation(fig, animate, outputFiles, blit=True, interval=25)

print "Starting to write animation file..."
# Set up formatting for the movie files
Writer = animation.writers['ffmpeg']

fps = 2
animationFileName = "animation"
if fps <= 2:
    animationFileName = animationFileName + "_slow.mp4"
if fps < 120:
    animationFileName = animationFileName + ".mp4"
else:
    animationFileName = animationFileName + "_fast.mp4"

writer = Writer(fps=fps, metadata=dict(artist='Alien'), bitrate=1800)
ani.save(os.path.join(graphicsOutputDirectory, animationFileName), writer=writer)
print "Finished writing animation file..."

When running the script in Linux (Debian Wheezy), I see the following output:

>>> python make_animation.py
Starting to run animation file...

In Windows, the script runs just fine. I have made sure that I am not making silly errors like using incorrect file names. Short animations seem to run just fine on my GNU/Linux machine and longer more serious ones seem to hang indefinitely...

What might the issue here be? I suppose a relevant detail I should mention is that I am using a virtualenvironment to run an up-to-date version of matplotlib.

Upvotes: 1

Views: 248

Answers (1)

Zulko
Zulko

Reputation: 3780

Ubuntu and Debian now ship with deprecated FFMPEG versions. That may be the issue. Try replacing the ffmpeg binary in your /usr/bin by a recent one from the FFMPEG website.

Another possible issue concerns Python 3, in which subprocess has a smaller buffer and will hang forever if ffmpeg sends too much informations back to Python. Are you on Python 3 ?

Upvotes: 1

Related Questions