Import OS Import CV2 Import numpy AS NP Import Time path = ' ./new_image/ ' Filelist = the os.listdir (path) FPS = 0.5 # of video per 0.5 # size of the image must be the same size = (512, 512) # video opencv avi format is read only video = cv2.VideoWriter ( " VideoTest1.avi " , cv2.VideoWriter_fourcc ( " M " , " J " , " P " , " G " ), FPS, size) # video saved in the current directory for item in filelist: IF item.endswith ( ' .jpg ' ): # find the path in all suffix .png files, you can replace a .jpg or other item path + = Item IMG = cv2.imread (Item) video.write (IMG) the time.sleep ( 2 ) Print ( " # " * 100 ) cap_cramer = cv2.VideoCapture ( " ./VideoTest1.avi " ) the while True: RET , Frame = cap_cramer.read() print("ret......", ret) print(frame) if ret is False: break cv2.imshow("frame", frame) cv2.waitKey(2000)