问题描述
下面是相关code片断:
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..."
当运行在Linux中(Debian的喘息)的剧本,我看到下面的输出:
When running the script in Linux (Debian Wheezy), I see the following output:
>>> python make_animation.py
Starting to run animation file...
在Windows中,脚本运行就好了。我已经确信,我不是愚蠢的错误,如不正确使用的文件名。动画短片似乎运行我的GNU / Linux机器和更长更严重的就好似乎无限期挂起...
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...
什么可能这里的问题是什么?我想,一个相关的细节,我应该提到的是,我使用的是virtualenvironment运行matplotlib的先进的最新版本。
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.
推荐答案
Ubuntu和Debian现在去$ P $出货pcated FFMPEG版本。这可能是问题。尝试通过从FFmpeg的网站上最近的一个替换你的/ usr / bin中的二进制文件的ffmpeg
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.
另一个可能的问题涉及Python 3中,其中有子较小的缓冲区,如果发送的ffmpeg太多的信息返回到Python将永远挂起。你对Python 3的?
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 ?
这篇关于matplotlib.animation:Windows下的脚本作品,并在Linux下适用于动画短片,但无限期地挂起更长的动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!