Python: Merge Images to the Video with OpenCV
作者:XD / 发表: 2022年4月20日 01:02 / 更新: 2022年4月20日 01:03 / 编程笔记 / 阅读量:1338
Python: Merge Images to the Video with OpenCV
import os
import cv2
image=cv2.imread("./result/img0001.jpg")
save_prefix = "./test_mp4/"
image_info=image.shape
height=image_info[0]
width=image_info[1]
size=(height,width)
print(size)
fps=24
fourcc=cv2.VideoWriter_fourcc(*"mp4v")
video = cv2.VideoWriter('video_name.mp4', cv2.VideoWriter_fourcc(*"mp4v"), fps, (width,height))
for root, dirs, files in os.walk(save_prefix):
files = sorted(files)
for img in files:
file_name = os.path.join(root, img)
image=cv2.imread(file_name)
video.write(image)