File size: 1,210 Bytes
748e637 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import logging, os
from utils.transcriber import transcriber
from utils.subtitler import subtitler
def process_video(invideo_file: str,
srt_file: str | None,
task: str,
max_words_per_line:int,
fontsize:str,
font:str,
bg_color:str,
text_color:str,
caption_mode:str,
config_file:str
):
invideo_path_parts = os.path.normpath(invideo_file).split(os.path.sep)
VIDEO_NAME = os.path.basename(invideo_file)
OUTVIDEO_PATH = os.path.join(os.path.normpath('/'.join(invideo_path_parts[:-1])), f"result_{VIDEO_NAME}")
if srt_file:
logging.info("Subtitling...")
subtitler(invideo_file, srt_file, OUTVIDEO_PATH, fontsize, font, bg_color, text_color, caption_mode)
else:
srt_file = os.path.normpath(f"{invideo_file.split('.')[0]}.srt")
transcriber(invideo_file, srt_file, max_words_per_line, task, config_file)
logging.info("Subtitling...")
subtitler(invideo_file, srt_file, OUTVIDEO_PATH, fontsize, font, bg_color, text_color, caption_mode)
return OUTVIDEO_PATH, srt_file
|