使用FFmpeg和IPython [英] Using FFmpeg and IPython

查看:125
本文介绍了使用FFmpeg和IPython的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我比较新的Python(我使用MATLAB更多)。我本来想要能够制作和保存动画。所以我去看看它是如何完成的,发现这个:
http:/ /jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/



我直接复制/粘贴了代码IPython笔记本。



我明白ffmpeg必须安装,我以为我做过(根据 http://www.wikihow.com/Install-FFmpeg-on-Windows )。路径为C:/ ffmpeg。当我在命令提示符下尝试ffmpeg -version时它会工作。它也适用于WinPython的命令提示符。我不知道是否有帮助,但Ipython的路径是:
C:\Users\Sal\WinPython-32bit-3.3.2.3\python-3.3.2\Scripts / p>

但是,它仍然不起作用。给出的错误是:
AttributeError:'str'对象没有属性'save'
当然,这个错误发生在.save命令。
我甚至尝试添加以下内容。不做任何额外的事情
writer ='ffmpeg'



我正在使用Windows 7,WinPython3.3。



非常感谢你

解决方案

我遇到了完全相同的当我开始使用完全相同的例子开始使用动画时出错。首先,



我正在使用Windows 7,Python 2.7.6,matplotlib 1.3.1



短答案:尝试通过

  mywriter = animation.FFMpegWriter()
anim.save(')设置FFMpegWriter, mymovie.mp4',writer = mywriter)

长回答:我确信有一个< strong> bug matplotblib.animation.save
有以下行

  if is_string_like(writer):

用户定义的作者实际上不是作家的功能,只是它的名字。然后,如果可以使用该作者的实例,则可以使用该作者的实例

  if writer in writers.avail:
writer = writers [作者](fps,编解码器,比特率,
extra_args = extra_args,
元数据=元数据

但是,这里是错误,如果用户定义的作者不在 writers.avail 中,它只是使用

  writer = writers.list()[0] 

它本身返回一个使用作者的名称的字符串,但是这个字符串实际上并没有用来实际写一个作者对象!


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/

I straight up copied/pasted the code in an IPython Notebook.

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:\Users\Sal\WinPython-32bit-3.3.2.3\python-3.3.2\Scripts /

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'

I am using Windows 7, WinPython3.3.

Thank you very much

解决方案

I came across the exact same error as I started working with animations using the exact same example to start with. First of all,

I am using Windows 7, Python 2.7.6, matplotlib 1.3.1

Short answer: Try to set up the FFMpegWriter yourself by

mywriter = animation.FFMpegWriter()
anim.save('mymovie.mp4',writer=mywriter)

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

However, and here is the bug, if the user defined writer is not in writers.avail it just uses

writer = writers.list()[0]

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆