使用 FFmpeg 和 IPython [英] Using FFmpeg and IPython
问题描述
我对 Python 比较陌生(我更多地使用 MATLAB).我基本上希望能够制作和保存动画.所以我去检查它是如何完成的,发现这个:http://jakevdp.github.io/blog/2012/08/18/matplotlib-动画教程/
I am relatively new to Python (I used MATLAB a lot more). I essentially want to be able to make and save animations. So I went and checked how it's done and found this : http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/
我直接将代码复制/粘贴到 IPython Notebook 中.
I straight up copied/pasted the code in an IPython Notebook.
我知道必须安装 ffmpeg,我认为我做到了(根据 http://www.wikihow.com/Install-FFmpeg-on-Windows).路径是 C:/ffmpeg.当我在命令提示符下尝试 ffmpeg -version 时它确实有效.它也适用于 WinPython 的命令提示符.我不知道它是否有帮助,但 Ipython 的路径是:C:UsersSalWinPython-32bit-3.3.2.3python-3.3.2Scripts/
I understand that ffmpeg must be installed, which I thought I did (according to http://www.wikihow.com/Install-FFmpeg-on-Windows). The path is C:/ffmpeg. It does work when I try ffmpeg -version in the command prompt. It also works in WinPython's command prompt. I don't know if it helps, but the path for Ipython is : C:UsersSalWinPython-32bit-3.3.2.3python-3.3.2Scripts /
然而,它仍然不起作用.给出的错误是:AttributeError:str"对象没有保存"属性这个错误当然发生在 .save 命令中.我什至尝试添加下面的内容.不做任何额外的事情.作家 = 'ffmpeg'
However, it still doesn't work. The error given is : AttributeError: 'str' object has no attribute 'saving' This error occurs at the .save command of course. I even tried to add what's below. Doesn't do anything extra. writer = 'ffmpeg'
我使用的是 Windows 7,WinPython3.3.
I am using Windows 7, WinPython3.3.
非常感谢
推荐答案
当我开始使用完全相同的示例开始处理动画时,我遇到了完全相同的错误.首先,
I came across the exact same error as I started working with animations using the exact same example to start with. First of all,
我使用的是 Windows 7、Python 2.7.6、matplotlib 1.3.1
I am using Windows 7, Python 2.7.6, matplotlib 1.3.1
简答:尝试自己设置 FFMpegWriter
Short answer: Try to set up the FFMpegWriter yourself by
mywriter = animation.FFMpegWriter()
anim.save('mymovie.mp4',writer=mywriter)
长答案:我很确定matplotblib.animation.save
中有一个错误有以下一行
Long answer: I am quite sure that there is a bug in matplotblib.animation.save
There is the following line
if is_string_like(writer):
捕捉用户定义的编写器实际上不是编写器函数而只是它的名称的情况.然后它实例化该作者的一个实例(如果它可用)
to catch the case that the user defined writer is actually not a writer function but just its name. It then instanciates an instance of that writer if it's available
if writer in writers.avail:
writer = writers[writer](fps, codec, bitrate,
extra_args=extra_args,
metadata=metadata
然而,这里是错误,如果用户定义的 writer 不在 writers.avail
中,它只会使用
However, and here is the bug, if the user defined writer is not in writers.avail
it just uses
writer = writers.list()[0]
本身返回一个字符串,其中包含要使用的作者的 name.然而,这个字符串并没有用于实际实例化一个 writer 对象!
which itself returns a string with the name of the writer to be used. However, this string is nowhere used to actually instanciate a writer object!
这篇关于使用 FFmpeg 和 IPython的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!