import shutil
import cv2
from tqdm import tqdm
SRC_FOLDER = "./o_file/after_op_1"
DST_FOLDER = "./o_file/after_op_3"
ENDWITH = ".MOV"
def make_video(fps, video_name):
src_paths = [os.path.join(SRC_FOLDER, path) for path in os.listdir(SRC_FOLDER) if path.endswith(".png")]
src_paths.sort()
sample_img = cv2.imread(src_paths[0])
h, w, _ = sample_img.shape
out = cv2.VideoWriter(DST_FOLDER+video_name, -1, fps, (w, h))
pbar = tqdm(src_paths)
for i, src_path in enumerate(pbar):
frame = cv2.imread(src_path)
# 实时显示处理过的帧图片
cv2.imshow('frame', output)
cv2.waitKey(1)
pbar.set_description(" COMPLETE ")
out.release()
# 关闭帧图片展示窗口
cv2.destroyAllWindows()
if __name__ == "__main__":
try:
shutil.rmtree(DST_FOLDER)
except OSError:
pass
import os
os.makedirs(DST_FOLDER)
fps_lst = [30]
fourcc_types = [-1]
for fps in fps_lst:
video_name = "/output_" + "_" + str(fps) + ENDWITH
print("\n Make video {} in fps:{}".format(video_name, fps))
make_video(fps, video_name)