I want to create mp4 video from images stored in a folder. I already rename all images like (1.jpg,2.jpg,...1000.jpg).
I want to create video with every 5 images (1-5,6-10,11-15,...,995-1000) to video with 5 fps and save video.
Input:- 1000 images.
Output:- 200 videos with 5fps.
You can populate every 5 images in a array and create the video accordingly
for i in range(1,20): #can base on number of image in your directory
if(i+4 > 20):
break
print(str(i)+" "+str(i+4)) # use this to append your image into array
img_array = []
for j in range(i, i+5):
filename = str(j)+".jpg"
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width,height)
img_array.append(img)
#Create Video
out = cv2.VideoWriter(video_file,cv2.VideoWriter_fourcc(*'MP4V'), fps, size)
for i in range(len(img_array)):
out.write(img_array[i])
out.release()
i = i+4