I have some graphs within a folder called jupyter with jpg format, I want to put them together to make a video out of them, but when I run the code, it does not save and show the video.
import cv2
import os
from os.path import isfile, join
def convert_pictures_to_video(pathIn, pathOut, fps, time):
frame_array=[]
files= [f for f in os.listdir(pathIn) if isfile(join(pathIn,f))]
for i in range (len(files)):
filename=pathIn+files[i]
img=cv2.imread(filename)
height, width, layers=img.shape
size=(width,height)
for k in range (time):
frame_array.append(img)
out=cv2.VideoWriter(pathOut, cv2.VideoWriter_fourcc(*'mp4v'),fps,size)
for i in range(len(frame_array)):
out.write(frame_array[i])
cv2.destroyAllWindows()
out.release()
pathIn='/Users/jupyter/'
pathOut='/Users/jupyter/video.avi'
fps=1
time=20
convert_pictures_to_video(pathIn, pathOut, fps, time