Google Colab中的Videowriter(CV2)未创建视频文件

时间:2020-10-30 00:26:47

标签: python google-colaboratory cv2

下面是我的代码,该代码在一个文件夹中有一堆图像,我想将它们拼接成视频(mp4)。

import cv2
import os
from cv2 import VideoWriter, imread

image_folder = "videooutput/"
video_name = "video"

images = [img for img in os.listdir(image_folder) if img.endswith(".jpg")]
frame = imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape

video = VideoWriter(video_name, 0, 1, (width,height))

for image in images:
    video.write(cv2.imread(os.path.join(image_folder, image)))

cv2.destroyAllWindows()
video.release()

我已经确认images包含文件列表(xxx.jpg),这是所有必需的文件。运行它时,我没有得到任何错误输出,甚至没有录像机内存实例...?

0 个答案:

没有答案