import os
import cv2
import time
def picvideo(path,size):
filelist = os.listdir(path)
filelist.sort(key=lambda x: int(x.split('-')[0]))
fps = 30
file_path = r"./" + '新合成视频:'+str(int(time.time())) + ".avi"
fourcc = cv2.VideoWriter_fourcc('I','4','2','0' )
video = cv2.VideoWriter( file_path, fourcc, fps, size )
for item in filelist:
if item.endswith('.jpg'):
item = path + '/' + item
img = cv2.imread(item)
video.write(img)
video.release() #释放
picvideo(r'./input',(1920,1080))