def METHOD_NAME(dir_path: str, frames: list, fps: int, cfg: Config):
    video_fname = "replay.mp4" if cfg.video_name is None else cfg.video_name
    if not video_fname.endswith(".mp4"):
        video_fname += ".mp4"
    tmp_name = os.path.join(project_tmp_dir(), video_fname)
    video_name = os.path.join(dir_path, video_fname)
    if frames[0].shape[0] == 3:
        frame_size = (frames[0].shape[2], frames[0].shape[1])
    else:
        frame_size = (frames[0].shape[1], frames[0].shape[0])
    resize = False
    if min(frame_size) < MIN_FRAME_SIZE:
        resize = True
        scaling_factor = MIN_FRAME_SIZE / min(frame_size)
        frame_size = (int(frame_size[0] * scaling_factor), int(frame_size[1] * scaling_factor))
    video = cv2.VideoWriter(tmp_name, cv2.VideoWriter_fourcc(*"mp4v"), fps, frame_size)
    for frame in frames:
        if frame.shape[0] == 3:
            frame = frame.transpose(1, 2, 0)
        if resize:
            frame = cv2.resize(frame, frame_size, interpolation=cv2.INTER_AREA)
        video.write(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
    video.release()
    os.system(f"ffmpeg -y -i {tmp_name} -vcodec libx264 {video_name}")
    log.debug(f"Replay video saved to {video_name}!")