在Python中以编程方式生成视频或动画GIF? [英] Programmatically generate video or animated GIF in Python?

查看:455
本文介绍了在Python中以编程方式生成视频或动画GIF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列要用来创建视频的图像.理想情况下,我可以为每个帧指定一个帧持续时间,但是固定帧速率也可以.我正在wxPython中进行此操作,因此可以渲染为wxDC,也可以将图像保存到文件中,例如PNG.是否有Python库可以让我从这些帧中创建视频(AVI,MPG等)或动画GIF?

I have a series of images that I want to create a video from. Ideally I could specify a frame duration for each frame but a fixed frame rate would be fine too. I'm doing this in wxPython, so I can render to a wxDC or I can save the images to files, like PNG. Is there a Python library that will allow me to create either a video (AVI, MPG, etc) or an animated GIF from these frames?

我已经尝试过PIL,但它似乎不起作用.有人可以用这个结论纠正我,还是可以建议其他工具箱?该链接似乎可以证明我对PIL的结论: http://www.somethinkodd.com/oddthinking/2005/12/06/python-imaging-library-pil-and-animated-gifs/

I've already tried PIL and it doesn't seem to work. Can someone correct me with this conclusion or suggest another toolkit? This link seems to backup my conclusion regarding PIL: http://www.somethinkodd.com/oddthinking/2005/12/06/python-imaging-library-pil-and-animated-gifs/

推荐答案

好,现在我正在使用ImageMagick.我将帧另存为PNG文件,然后从Python调用ImageMagick的convert.exe创建动画GIF.关于这种方法的好处是,我可以为每个帧分别指定一个帧持续时间.不幸的是,这取决于在计算机上安装了ImageMagick.他们有一个Python包装器,但是看起来很烂而且不受支持.仍然欢迎其他建议.

Well, now I'm using ImageMagick. I save my frames as PNG files and then invoke ImageMagick's convert.exe from Python to create an animated GIF. The nice thing about this approach is I can specify a frame duration for each frame individually. Unfortunately this depends on ImageMagick being installed on the machine. They have a Python wrapper but it looks pretty crappy and unsupported. Still open to other suggestions.

这篇关于在Python中以编程方式生成视频或动画GIF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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