Python JPEG到电影 [英] Python JPEG to movie

查看:88
本文介绍了Python JPEG到电影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,用Python将图像文件目录(例如JPEG)连接到电影文件(MOV,MP4,AVI)。理想情况下,这也允许我从该目录中获取多个JPEG并将它们粘贴到网格中,该网格是电影文件的一帧。哪些模块可以达到这个目的?

I am looking for a way to concatenate a directory of images files (e.g., JPEGs) to a movie file (MOV, MP4, AVI) with Python. Ideally, this would also allow me to take multiple JPEGs from that directory and "paste" them into a grid which is one frame of a movie file. Which modules could achieve this?

推荐答案

你可以使用 OpenCV的Python界面,特别是 VideoWriter 可能会完成这项工作。根据我对文档的理解,以下内容可以满足您的需求:

You could use the Python interface of OpenCV, in particular a VideoWriter could probably do the job. From what I understand of the doc, the following would do what you want:

w = cvCreateVideoWriter(filename, -1, <your framerate>, 
                        <your frame size>, is_color=1)

和,循环中,每个文件:

and, in a loop, for each file:

cvWriteFrame(w, frame)

请注意,我没有尝试过这段代码,但我认为我的想法是正确的。请告诉我它是否有效。

Note that I have not tried this code, but I think that I got the idea right. Please tell me if it works.

这篇关于Python JPEG到电影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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