[英]How to set ffmpeg for matplotlib in mac os x
I want to animate some plots with matplotlib. 我想用matplotlib动画一些情节。 The version I have is the Enthough Canopy distribution (Version: 1.1.0.1371), running in a mac os x 10.8 (Mountain Lion).
我的版本是Enthough Canopy发行版(版本:1.1.0.1371),在mac os x 10.8(Mountain Lion)中运行。 I have used the FuncAnimation routine from the animation package of matplotlib.
我使用了matplotlib动画包中的FuncAnimation例程。 My problem comes saving the animation.
我的问题是保存动画。 I want to save in mp4 format:
我想以mp4格式保存:
anim.save('test.mp4',fps=30)
The error I get is: 我得到的错误是:
UserWarning: MovieWriter ffmpeg unavailable
warnings.warn("MovieWriter %s unavailable" % writer)
So I installed ffmpeg via Macports. 所以我通过Macports安装了ffmpeg。 But I am still having the same error.
但我仍然有同样的错误。 Do you know how to setup matplotlib in order to recognise ffmpeg?
你知道如何设置matplotlib以识别ffmpeg吗? Do I have to change the matplotlibrc file?
我是否必须更改matplotlibrc文件? Thanks.
谢谢。
EDIT: I have realized that I can manually put '/opt/local/bin' in the PYTHONPATH, but it does not change the PATH in Enthough Canopy. 编辑:我已经意识到我可以手动将'/ opt / local / bin'放在PYTHONPATH中,但它不会改变Enthough Canopy中的PATH。 Do anyone know how to change the PATH in canopy?
有谁知道如何改变树冠的PATH?
I think the solution can be found in the workaround in this and this post. 我认为解决方案可以在本文和本文的解决方法中找到。
It seems that the path of the shell is not loaded by matplotlib, and since macports are installed in /opt/local/bin
, ffmpeg
can't be found. 似乎shell的路径没有被matplotlib加载,并且由于macports安装在
/opt/local/bin
,因此无法找到ffmpeg
。
Either go for the hack described above, try making a symlink in /bin
for ffmpeg
, or try adding the path to ffmpeg
to the python path as suggested in the comments of the second link 要么去上面描述的hack,尝试在
/bin
为ffmpeg
创建一个符号链接,或者尝试将ffmpeg
的路径添加到python路径,如第二个链接的注释中所建议的
I had success when installing with homebrew: brew install ffmpeg
使用自制软件
brew install ffmpeg
时我取得了成功: brew install ffmpeg
After that set up the FFMpegWriter yourself by: 之后通过以下方式自行设置FFMpegWriter:
mywriter = animation.FFMpegWriter()
anim.save('mymovie.mp4',writer=mywriter)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.