I am trying to take 2 images present in a local folder and use OpenCV's Videowriter function to create a video from these images. I am using FrameRate of 1. So this creates a video of 2 seconds duration. Below is the code (I got it from here):
import cv2
import os
image_folder = 'images'
video_name = 'video.avi'
images = [img for img in os.listdir(image_folder) if img.endswith(".png")]
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
video = cv2.VideoWriter(video_name, 0, 1, (width,height))
for image in images:
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()
Goal: I want to create a video of 10 seconds which will have these 2 images each being displayed for 5 seconds.
I think there might be a similar question like this in the forum but I am not able to find it. If someone can point me to the solution, it would be great.
Thank you.