import os
import time
from pathlib import Path
from utils.audio_analysis import audio_analysis_pipeline
from modules.video_processing.video_concat import merge_videos
from modules.video_processing.video_cut import video_cut_by_json

from utils.llm_director import director_json
from utils.video_concat import concat_videos
from utils.common import read_video_list, find_vidoe2cut

from utils.first_cut import cut_once
from utils.oral_cut import oral_cut
from utils.aide_cut import aide_cut
from utils.show_cut import show_cut
from utils.logger_config import setup_logger

logger = setup_logger(__name__)

def main(video_path):
    print("start!")

    start = time.time()
    # 1、同款衣服视频裁切
    _, video_list = cut_once(video_path)

    for sub_video in video_list:
        # 2、口播视频裁切拼接
        video_2 = oral_cut(sub_video)

        # 3、走秀视频片段裁切 + 配乐
        audio_json = f"data/audio_json/{Path(sub_video).stem}.json"
        video_3 = show_cut(audio_json)

        # 4、口播走秀片段拼接
        concat_videos([video_2, video_3])

    logger.info(f"total cost {time.time() - start} sec.")


if __name__ == "__main__":

    main("data/raw_video/rawvideo.flv")