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.