下面是我的代码,该代码在一个文件夹中有一堆图像,我想将它们拼接成视频(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),这是所有必需的文件。运行它时,我没有得到任何错误输出,甚至没有录像机内存实例...?