import cv2
import os
import random
import glob

H_canvas, W_canvas = 900,1300
out_path = "/home/zhiwen/projects/SymReL_original/data/videos/video#2_all.mp4"

videowriter = cv2.VideoWriter(out_path, cv2.VideoWriter_fourcc(*'mp4v'), 100, (W_canvas, H_canvas))
mp4list = glob.glob(os.path.join("/home/zhiwen/projects/SymReL_original/data/videos/video#2","*.mp4"))
mp4list = sorted(mp4list)
cnt = 1
for mp4file in mp4list:
    print("mp4file:", mp4file)
    capture = cv2.VideoCapture(mp4file)

    while capture.isOpened():
        
        ret, prev =capture.read()
        if ret:
            cnt += 1
            # print("cnt:", cnt)
            videowriter.write(prev)
        else:
            break
videowriter.release()
cv2.destroyAllWindows()
