Files
lesson-highlights/docs/USAGE.md
T
hmo 9d0ed5820d feat(gui): implement GUI edit mode with atomic clip operations
Phase 2 complete - GUI editing layer on top of Phase 1 CLI:

Config:
- config.py now only has API keys (API_KEY, API_HOST, PYTHON, CLI_DIR)
- Project paths (video_src, ppt_path, max_total_duration) in generated_config.yaml

Atomic clip operations (Pipeline methods):
- reextract_clip(clip_index, new_title) - re-match title in transcript
- delete_clip(clip_index) - remove clip and its intermediate files
- add_clip_by_title(new_title) - match new title, handle overlaps
- reburn_titles() - re-burn title track from updated clips
- reburn_subtitles(user_texts) - burn user-edited subtitles directly
- _find_title_in_transcript() - substring match in corrected transcript

GUI:
- Two startup modes: new project / open existing project
- Clip list with double-click rename, right-click delete, + add
- Subtitle preview with direct text editing
- Apply button orchestrates reburn_titles/reburn_subtitles
- Unmatched clips shown with warning label, excluded from burn

CLI/GUI interoperability:
- Both use same generated_config.yaml as single source of truth
- CLI: run.bat for full pipeline, burn.bat for quick reburn
- GUI: open project dir, edit, apply

Docs:
- USAGE.md updated with GUI edit mode documentation
2026-05-04 01:06:59 +08:00

186 lines
5.3 KiB
Markdown
Raw 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`
## GUI 编辑模式
### 启动方式
GUI 支持两种启动模式:
**方式一:新建项目**
```bash
python src/main.py
# 或双击 start.bat
```
在启动页选择"新建项目",选择视频+PPT,运行完整流程。
**方式二:打开已有项目**
在启动页选择"打开已有项目",选择 output 目录。
项目文件 `generated_config.yaml` 包含所有项目信息(视频路径、PPT路径、知识点列表)。
### 编辑知识点
打开项目后进入编辑界面:
- **改标题**:双击 clip 列表中的任意条目,输入新标题 → 系统自动在 transcript 中重新匹配时间段 → 处理重叠
- **删 clip**:右键点击 clip → 删除此 Clip
- **新增知识点**:点击"+ 新增知识点"按钮,输入标题 → 系统在 transcript 中匹配 → 如有重叠自动合并
> 注意:匹配不到的 clip 显示红色背景的"未匹配"标签,不参与最终烧录
### 编辑字幕
右侧字幕预览区显示 `v1_content.srt` 内容,可直接编辑文本。
### 应用更改
点击"应用"按钮:
1. 检测字幕是否有修改 → 有则重烧字幕轨
2. 检测 clips 是否有修改 → 重烧标题轨
3. 自动合并+烧录最终视频
### 文件结构
```
output_dir/
├── generated_config.yaml ← 项目文件(GUI 编辑后同步更新)
├── intermediates/ ← 中间缓存
│ ├── clip*.json ← Whisper 转录(删后可重新生成)
│ ├── clip*.mp4 ← 视频片段
│ └── corrected_transcript.json ← LLM校正后的全量转录
├── subs/
│ ├── v1_title.srt ← 标题轨
│ └── v1_content.srt ← 字幕轨(可直接编辑)
└── final.mp4 ← 最终输出
```
## CLI/GUI 互操作
CLI 和 GUI 共用同一套项目文件体系:
```bash
# 1. CLI 批量处理
run.bat
# 2. GUI 审核修改
python src/main.py
# → 选择"打开已有项目" → 选择同一 output_dir
```
修改后点"应用",GUI 自动判断需要重生成哪些部分。