Files
hmo aad1548348 refactor: extract config.py, add burn_only, fix title_segments and font size
- Extract all path/API config to config.py (single source of truth)
- Add run.py / burn_only.py / run.bat / burn.bat entry points
- burn_only: skip transcription/subtitle gen, fast reburn existing SRTs
- Fix title_segments: use transcript keyword time for split point
- Fix subtitle: each overlapping title shows max title_duration (not full clip)
- Fix burn_only font size: default from 90 to 60
- Delete old run_lesson1.bat/py, temp debug scripts
- Update README, ARCHITECTURE, CHANGELOG, add USAGE.md
2026-05-03 23:22:10 +08:00

118 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 使用指南
## 快速开始
### 1. 配置
编辑项目根目录的 `config.py`
```python
VIDEO = r"D:\...\直播回放.mp4"
PPT = r"D:\...\课程.pptx"
OUTPUT = r"D:\...\output"
MAX_TOTAL_DURATION = 600 # 精华片段总时长上限(秒)
API_KEY = "your-api-key"
API_HOST = "https://ark.cn-beijing.volces.com/api/coding/v3"
```
所有路径和 API 配置只改这一个文件。
### 2. 完整流程(首次运行)
```bash
run.bat
```
或直接:
```bash
python run.py
```
完整流程:PPT解析 → Whisper转录 → LLM校正 → 字幕生成 → 合并 → 烧录
### 3. 修改字幕后快速重烧
改完 `v1_title.srt``v1_content.srt` 后,直接:
```bash
burn.bat
```
跳过所有转录/字幕生成步骤,直接用已有片段和字幕文件合并烧录。**只改字幕文本时用这个**。
## 修改知识点(替换PPT中的某个知识点)
LLM 从 PPT 提取了 clip 后,如果你想把其中一个换成 PPT 里另一个知识点(比如把"音高"换成"旋律"):
### 步骤
1. **改 `generated_config.yaml`**:把对应 clip 的 title 改成新知识点名称
```yaml
clips:
- title: 旋律 # ← 改成PPT里有的知识点
start: 200
end: 260
```
2. **删该 clip 的中间文件**(让它重新生成):
```
intermediates/clip5.json ← 删掉
intermediates/clip5.mp4 ← 删掉
```
3. **重新运行**
```bash
run.bat
```
系统会跳过其他已有 JSON 的 clip,只重新生成被删除了 JSON 的那一个 clip。
### 原理
- `run.bat` 检测到 `clip*.json` 已存在,就跳过 Whisper 转录
- 删掉某个 clip 的 JSON 后,系统认为它需要重新生成
- 重新生成时用新的 title 去 transcript 里匹配,重新找时间范围
### 注意
- `start`/`end` 如果填错了,生成的视频片段时间会不对
- 如果不确定新知识点的时间范围,可以先随便填一个,跑完看效果再调整
## 文件结构
```
output/
├── generated_config.yaml # clips 配置(可手动修改)
├── intermediates/ # 中间文件(可删除特定clip的.json/.mp4重生成)
│ ├── clip1.json # Whisper 转录结果
│ ├── clip1.mp4 # 提取的视频片段
│ └── ...
├── subs/ # 字幕文件
│ ├── v1_title.srt # 标题轨(可手动修改文本+时间轴)
│ └── v1_content.srt # 正文字幕
├── concat_merged.mp4 # 合并后的视频
└── final.mp4 # 最终输出
```
## 命令对比
| 命令 | 用途 | 耗时 |
|------|------|------|
| `run.bat` | 完整流程(PPT→视频) | 几十分钟 |
| `burn.bat` | 只改字幕后快速重烧 | 几分钟 |
## 常见问题
**Q: `burn.bat` 改了字号没变化?**
A: `burn.bat` 直接烧已有的 SRT 文件,不走 `subtitle.py` 的生成逻辑。如果改了渲染参数(如字号)需要重新生成字幕,必须 `run.bat`
**Q: 想改某个知识点的出现时间?**
A: 直接改 `v1_title.srt` 里的时间轴,或者改 `generated_config.yaml` 然后删对应 clip 的 JSON 重新生成。
**Q: 想删掉某个 clip**
A: 从 `generated_config.yaml` 里删掉那一条,然后删对应 `intermediates/clip*.json``clip*.mp4`,最后 `run.bat`