Created
November 4, 2022 07:16
-
-
Save IzumiSatoshi/45de593f35c3caf7d58dd103a18663cc to your computer and use it in GitHub Desktop.
Output horizontally merged mp4 from two directories containing video frames.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !!!IMPORTANT!!! The output must be encoded once, e.g. with a video editor, as it may contain errors that make it unplayable as it is. | |
import cv2 | |
import glob | |
#### change here | |
left_frames_dir_path ="C:/Users/81809/Desktop/Projects/nicolai_fewshot/Few-Shot-Patch-Based-Training/logs/1_gen/res__P_disco1010/0020000" | |
right_frames_dir_path = "C:/Users/81809/Desktop/Projects/nicolai_fewshot/Few-Shot-Patch-Based-Training/logs/1_gen/input_filtered" | |
fps = 24 | |
output_video_path = "woman_dance_greg2.mp4" #mp4 only | |
input_frames_height = 512 | |
input_frames_width = 512 | |
#### | |
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') | |
video = cv2.VideoWriter(output_video_path,fourcc, fps, (input_frames_width*2, input_frames_height)) | |
left_frames_path_list = glob.glob(left_frames_dir_path+"/*") | |
right_frames_path_list = glob.glob(right_frames_dir_path+"/*") | |
for left_frame_path, right_frame_path in zip(left_frames_path_list, right_frames_path_list): | |
left_frame = cv2.imread(left_frame_path) | |
right_frame = cv2.imread(right_frame_path) | |
output_frame = cv2.hconcat([left_frame, right_frame]) | |
video.write(output_frame) | |
video.release() | |
print('done. enjoy:D') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment