|
import cv2 |
|
import os |
|
import imageio |
|
|
|
|
|
images_folder = 'output/blender_reder' |
|
|
|
|
|
image_filenames = os.listdir(images_folder) |
|
image_filenames.sort() |
|
|
|
|
|
frame_width = 1920 |
|
frame_height = 1080 |
|
|
|
|
|
video_output_filename = 'output/blender_reder/output_video.mp4' |
|
fps = 3.0 |
|
fourcc = cv2.VideoWriter_fourcc(*'mp4v') |
|
video_writer = cv2.VideoWriter(video_output_filename, fourcc, fps, (frame_width, frame_height)) |
|
|
|
|
|
IMG_NUM = 20 |
|
frames = [] |
|
|
|
for image_filename in image_filenames[:IMG_NUM]: |
|
image_path = os.path.join(images_folder, image_filename) |
|
image = cv2.imread(image_path) |
|
|
|
|
|
resized_image = cv2.resize(image, (frame_width, frame_height)) |
|
|
|
|
|
video_writer.write(resized_image) |
|
frames.append(resized_image) |
|
|
|
|
|
video_writer.release() |
|
|
|
print("Video concatenation complete.") |
|
|
|
with imageio.get_writer("output/blender_reder/output_video.gif", mode="I") as writer: |
|
for idx, frame in enumerate(frames): |
|
print("Adding frame to GIF file: ", idx + 1) |
|
writer.append_data(frame[...,[2,1,0]]) |