81 lines
2.3 KiB
Python
81 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""
|
||
快速烧录脚本 - 跳过所有转录/字幕生成步骤
|
||
直接用已有的 clips + title.srt + content.srt 合并烧录
|
||
|
||
用法:
|
||
python burn_only.py "D:\\path\\to\\output_dir"
|
||
"""
|
||
import sys
|
||
import os
|
||
|
||
# 必须指定输出目录
|
||
if len(sys.argv) < 2:
|
||
print("用法: python burn_only.py <output_dir>")
|
||
print("示例: python burn_only.py \"D:\\path\\to\\output_dir\"")
|
||
sys.exit(1)
|
||
|
||
OUTPUT = sys.argv[1]
|
||
|
||
TITLE_SRT = os.path.join(OUTPUT, "subs", "v1_title.srt")
|
||
CONTENT_SRT = os.path.join(OUTPUT, "subs", "v1_content.srt")
|
||
CLIPS_DIR = os.path.join(OUTPUT, "intermediates")
|
||
MERGED_PATH = os.path.join(OUTPUT, "concat_merged.mp4")
|
||
|
||
print(f"[Fast Burn Mode]")
|
||
print(f"Output: {OUTPUT}")
|
||
print()
|
||
|
||
# 检查必要文件
|
||
if not os.path.exists(TITLE_SRT):
|
||
print(f"ERROR: title.srt not found\n{TITLE_SRT}")
|
||
sys.exit(1)
|
||
if not os.path.exists(CONTENT_SRT):
|
||
print(f"ERROR: content.srt not found\n{CONTENT_SRT}")
|
||
sys.exit(1)
|
||
|
||
# 导入 pipeline(src 目录)
|
||
src_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "src")
|
||
sys.path.insert(0, src_dir)
|
||
from core import Pipeline
|
||
|
||
# 尝试从 generated_config.yaml 加载配置
|
||
config_path = os.path.join(OUTPUT, 'generated_config.yaml')
|
||
if os.path.exists(config_path):
|
||
import yaml
|
||
with open(config_path, 'r', encoding='utf-8') as f:
|
||
pipeline_config = yaml.safe_load(f) or {}
|
||
pipeline_config['output_dir'] = OUTPUT
|
||
else:
|
||
# 构造 minimal config
|
||
pipeline_config = {
|
||
'output_dir': OUTPUT,
|
||
'clips': [],
|
||
'video_src': None,
|
||
'video_params': {},
|
||
'term_corrections': {},
|
||
'api_key': '',
|
||
'api_host': '',
|
||
}
|
||
|
||
pipeline = Pipeline(pipeline_config)
|
||
|
||
# 合并视频(如需要)
|
||
if os.path.exists(MERGED_PATH):
|
||
print(f"Found existing merged video: {MERGED_PATH}")
|
||
merged_path = MERGED_PATH
|
||
else:
|
||
import glob
|
||
clip_files = sorted(glob.glob(os.path.join(CLIPS_DIR, "clip*.mp4")))
|
||
if not clip_files:
|
||
print(f"ERROR: No clip videos found\n{CLIPS_DIR}\\clip*.mp4")
|
||
sys.exit(1)
|
||
print(f"Merging {len(clip_files)} clips...")
|
||
merged_path = pipeline.step_merge(clip_files)
|
||
print(f"Merged: {merged_path}")
|
||
|
||
# 烧录
|
||
print("Burning subtitles...")
|
||
final_path = pipeline.step_burn(merged_path, TITLE_SRT, CONTENT_SRT)
|
||
print(f"\nDone: {final_path}")
|