和平精英 / PUBG 游戏精彩击杀自动剪辑工具 Auto highlight clipping for PUBG / Peace Elite gameplay
A desktop application that detects kill events in gameplay videos via OCR and exports highlight clips. 通过 OCR 识别游戏视频中的击杀文字,自动导出精彩击杀片段。
| Dual Platform / 双平台 | mobile (PUBG Mobile/和平精英) + PC (PUBG PC) toggle, per-platform state isolation |
| Language Presets / 语言预设 | 7 presets: zh_CN, zh_TW, en, ja, ko for both platforms, toolbar quick-switch |
| Video Player / 视频播放器 | frame-by-frame, rotation, drag-and-drop, audio playback / 逐帧、旋转、拖拽、音频播放 |
| Keyboard Shortcuts / 快捷键 | Space: play/pause, ←→: prev/next frame / 空格: 播放暂停, 方向键: 逐帧 |
| Timeline / 时间轴 | ruler, clip markers, zoom, playhead drag, click-to-seek / 刻度尺、片段标记、缩放、游标拖拽 |
| Smart Seek / 智能跳转 | double-click clip → jump 1.5s before trigger / 双击片段精准跳转 |
| ROI Annotation / 区域标注 | multi-label boxes, per-platform default templates / 多标签框选、分平台默认模板 |
| OCR Detection / 文字识别 | RapidOCR + EasyOCR, GPU acceleration, pool pipeline (CPU/GPU workers) |
| Keyword Matching / 关键词匹配 | exact + fuzzy matching, vehicle hit events, kill/knockdown/team events |
| Cell Divide / 细胞分裂 | gap binary search for precise event boundaries / 间隙二分搜索精确事件边界 |
| Logging System / 日志系统 | file rotation + Qt bridge + crash capture / 文件轮转、GUI桥接、崩溃捕获 |
| Smart Export / 智能导出 | FFmpeg + NVENC/AMF/QSV hardware encode / GPU硬件编码 |
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Stage 1 │───▶│ Stage 2 │───▶│ Stage 3 │
│ Mark │ │ Detect │ │ Export │
│ 标注区域 │ │ OCR检测 │ │ 视频导出 │
└──────────┘ └──────────┘ └──────────┘
app/
├── core/ # Pure logic / 纯逻辑
│ ├── player.py # Video engine / 视频引擎
│ ├── annotator.py # Label model / 标注数据模型
│ ├── keywords.py # Pattern matching / 关键词匹配
│ ├── detector.py # OCR pipeline / OCR流水线
│ ├── exporter.py # FFmpeg engine / 导出引擎
│ ├── presets.py # Preset manager / 预设管理
│ ├── project.py # Project state (per-platform) / 项目状态
│ ├── roi_templates.py # ROI template CRUD / ROI模板
│ └── coarse_to_fine.py # Boundary refinement / 边界精化
├── ui/ # PySide6 GUI
│ ├── main_window.py # Main window / 主窗口
│ ├── video_player.py # Player widget / 播放器
│ ├── timeline.py # Timeline widget / 时间轴
│ ├── overlay.py # Annotation overlay / 标注层
│ ├── side_panel.py # Side panel (tags, templates) / 侧边栏
│ ├── settings_dialog.py # Settings dialog / 设置对话框
│ └── log_window.py # Log viewer / 日志查看器
├── utils/ # Utilities / 工具
│ └── logger.py # Logging system / 日志系统
└── workers/ # QThread workers / 后台线程
cli.py # CLI tool / 命令行工具
Prerequisites / 前置要求: Python 3.10+, FFmpeg (in PATH)
git clone https://github.com/Friend-Xu/GameVideoEdit.git
cd GameVideoEdit
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -r requirements.txt
# GPU加速 (optional / 可选)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118Launch / 启动:
python app/main.py
# or double-click / 或双击 启动.batWorkflow / 使用流程:
- Open video / 打开视频 → 2. Draw ROIs / 框选击杀提示区 → 3. Save labels / 保存标注 → 4. OCR detect / OCR识别 → 5. Export / 导出集锦
无需 GUI 即可运行 OCR 检测和导出,适合批处理和 CI/CD 集成。
# 环境验证
python cli.py verify
# 查看视频信息
python cli.py info video.mp4
# 关键词匹配测试
python cli.py match "你使用 M416 击倒了 玩家"
python cli.py match -i # 交互式测试
# OCR 检测 — Pool 模式 (推荐, CPU/GPU 多线程)
python cli.py detect video.mp4 --pipeline pool --cell-divide \\
--config config/presets/pubg_pc_zh.yaml
# OCR 检测 — Legacy 模式
python cli.py detect video.mp4 --roi video.roi.json -o results.json
# OCR 检测 (手动指定 ROI 区域)
python cli.py detect video.mp4 --roi-region 100,200,300,50 --mode time --interval 1.0
# 过滤特定角色
python cli.py detect video.mp4 --roi video.roi.json --actors 自己,队友
# 导出视频片段
python cli.py export video.mp4 results.json -o highlights.mp4| 命令 | 说明 |
|---|---|
verify |
验证运行环境 (Python, FFmpeg, GPU) |
info |
查看视频元信息、ROI 标注、已有检测结果 |
match |
测试关键词匹配规则 |
detect |
运行 OCR 检测,支持 time/frame 两种模式 |
export |
根据检测结果导出剪辑视频 |
Edit config/default.yaml / 编辑 config/default.yaml:
| Key | Default | Description / 说明 |
|---|---|---|
ocr.engine |
rapidocr | OCR engine: easyocr / rapidocr |
ocr.gpu |
true | Enable GPU / 启用GPU加速 |
ocr.confidence_threshold |
0.5 | Min OCR confidence / 最低置信度 |
detection.mode |
frame | Detection mode: time / frame |
detection.pipeline_mode |
pool | Pipeline mode: legacy / pool |
detection.padding_before |
5.0 | Seconds before kill / 击杀前秒数 |
detection.padding_after |
5.0 | Seconds after kill / 击杀后秒数 |
detection.cell_divide |
true | Gap binary search / 细胞分裂精确边界 |
detection.gate_mode |
neural | Text gate: pixel / neural |
detection.cpu_workers |
6 | Pool mode CPU threads / CPU线程数 |
detection.gpu_workers |
4 | Pool mode GPU threads / GPU线程数 |
export.quality |
23 | CRF/CQ (lower=better / 越低越好) |
GPL v3 © Friend-Xu