docs: add processor configuration v2/v3 with full commands

新增配置文件:
- processor_tools_v2.json: Tool/Model 分離設計
- processor_tools_v3.json: 完整命令和參數

新增文檔:
- Processor_Config_V2_Design.md: V2 設計文檔
- Processor_Commands_Reference.md: 完整命令參考

V3 配置特點:
- 明確區分 tool (python/rust/swift) 和 model (whisper/mediapipe)
- 包含完整執行命令和參數
- 支持變量替換 ({video_path}, {file_uuid}, etc.)
- 包含環境變量配置

命令示例:
- POSE (Python): python3.11 scripts/pose_processor_mediapipe.py {video} {output} --model-complexity 2
- FACE_TRACE (Rust): rust_store_traced_faces {uuid} --output-dir {dir}
- ASR (Python): python3.11 scripts/asr_processor_simplified.py {video} {output} --model large-v3

下一步:
- 更新 ToolSelector 支持 V3 格式
- 更新 Worker 使用新配置
This commit is contained in:
Accusys
2026-09-28 11:04:33 +08:00
parent f15842e9cf
commit 7d5afba1cd
4 changed files with 1526 additions and 0 deletions
@@ -0,0 +1,396 @@
---
title: Processor Commands Reference
version: 3.0
date: 2026-09-27
author: OpenCode
status: active
---
## 概覽
本文檔列出所有 Processor 的實際執行命令和參數。
---
## POSE (姿態檢測)
### Python + MediaPipe
```bash
/opt/homebrew/bin/python3.11 \
scripts/pose_processor_mediapipe.py \
{video_path} \
{output_path} \
--uuid {file_uuid} \
--model-complexity 2
```
**參數**:
- `video_path`: 視頻文件路徑 (必需)
- `output_path`: 輸出 JSON 路徑 (必需)
- `--uuid`: 視頻 UUID (可選)
- `--model-complexity`: 模型複雜度 (0/1/2,默認 2)
**輸出**: `{file_uuid}.pose.json`
---
### Rust
```bash
tools/cli/rust/target/release/rust_pose \
--video {video_path} \
--output {output_path} \
--uuid {file_uuid}
```
**參數**:
- `--video`: 視頻文件路徑 (必需)
- `--output`: 輸出 JSON 路徑 (必需)
- `--uuid`: 視頻 UUID (可選)
**輸出**: `{file_uuid}.pose.json`
---
### Swift
```bash
tools/cli/swift/.build/release/swift_pose \
{video_path} \
--output {output_path} \
--uuid {file_uuid}
```
**參數**:
- `video_path`: 視頻文件路徑 (必需,位置參數)
- `--output`: 輸出 JSON 路徑 (必需)
- `--uuid`: 視頻 UUID (可選)
**輸出**: `{file_uuid}.pose.json`
---
## FACE (人臉檢測)
### Swift
```bash
tools/cli/swift/.build/release/swift_face \
{video_path} \
--output {output_path} \
--uuid {file_uuid}
```
**輸出**: `{file_uuid}.face.json`
---
### Python + FaceNet
```bash
/opt/homebrew/bin/python3.11 \
scripts/face_detector.py \
{video_path} \
{output_path} \
--uuid {file_uuid} \
--model facenet
```
**參數**:
- `--model`: 模型名稱 (facenet)
**輸出**: `{file_uuid}.face.json`
---
## ASR (語音識別)
### Python + Whisper
```bash
/opt/homebrew/bin/python3.11 \
scripts/asr_processor_simplified.py \
{video_path} \
{output_path} \
--model large-v3
```
**參數**:
- `--model`: Whisper 模型大小 (tiny/base/small/medium/large/large-v3)
**輸出**: `{file_uuid}.asr.json`
---
## ASRX (說話人分離)
### Swift
```bash
tools/cli/swift/.build/release/swift_asrx \
{video_path} \
--output {output_path} \
--uuid {file_uuid}
```
**輸出**: `{file_uuid}.asrx.json`
---
### Python
```bash
/opt/homebrew/bin/python3.11 \
scripts/asrx_processor.py \
{video_path} \
{output_path} \
--uuid {file_uuid}
```
**輸出**: `{file_uuid}.asrx.json`
---
## OCR (光學字符識別)
### Swift
```bash
tools/cli/swift/.build/release/swift_ocr \
{video_path} \
--output {output_path} \
--uuid {file_uuid}
```
**輸出**: `{file_uuid}.ocr.json`
---
### Python + Tesseract
```bash
/opt/homebrew/bin/python3.11 \
scripts/ocr_processor.py \
{video_path} \
{output_path} \
--uuid {file_uuid}
```
**輸出**: `{file_uuid}.ocr.json`
---
## FACE_TRACE (人臉追蹤)
### Rust
```bash
tools/cli/rust/target/release/rust_store_traced_faces \
{file_uuid} \
--output-dir {output_dir} \
--min-trace-len 0 \
--min-confidence 0.0
```
**參數**:
- `file_uuid`: 視頻 UUID (必需,位置參數)
- `--output-dir`: 輸出目錄 (默認: /Users/accusys/momentry/output)
- `--min-trace-len`: 最小 trace 長度 (默認: 0)
- `--min-confidence`: 最小置信度 (默認: 0.0)
**輸出**: `{file_uuid}.face_traced.json`
---
### Python
```bash
/opt/homebrew/bin/python3.11 \
scripts/store_traced_faces.py \
--file-uuid {file_uuid} \
--face-json {face_json}
```
**參數**:
- `--file-uuid`: 視頻 UUID (必需)
- `--face-json`: face.json 路徑 (可選,自動檢測)
**輸出**: `{file_uuid}.face_traced.json`
---
## SCENE_VLM_SUMMARY (場景描述)
### Python + Gemma4
```bash
/opt/homebrew/bin/python3.11 \
scripts/scene_vlm_summary.py \
--file-uuid {file_uuid} \
--output-dir {output_dir} \
--llm-url http://localhost:8080/v1/chat/completions \
--max-tokens 300
```
**參數**:
- `--file-uuid`: 視頻 UUID (必需)
- `--output-dir`: 輸出目錄
- `--llm-url`: LLM API URL
- `--max-tokens`: 最大 token 數
**輸出**: `{file_uuid}.scene_vlm.json`
---
## TKG (時間知識圖譜)
### Python
```bash
/opt/homebrew/bin/python3.11 \
scripts/build_tkg.py \
--file-uuid {file_uuid} \
--output-dir {output_dir}
```
**輸出**: `{file_uuid}.tkg.json`
---
## CUT (場景切換)
### Rust
```bash
tools/cli/rust/target/release/rust_cut \
{video_path} \
--output {output_path} \
--uuid {file_uuid} \
--min-scene-duration 0.5
```
**參數**:
- `video_path`: 視頻文件路徑 (必需,位置參數)
- `--output`: 輸出 JSON 路徑
- `--uuid`: 視頻 UUID
- `--min-scene-duration`: 最小場景時長 (秒)
**輸出**: `{file_uuid}.cut.json`
---
### Python
```bash
/opt/homebrew/bin/python3.11 \
scripts/cut_detector.py \
{video_path} \
{output_path} \
--uuid {file_uuid}
```
**輸出**: `{file_uuid}.cut.json`
---
## 變量替換表
| 變量 | 說明 | 示例 |
|------|------|------|
| `{video_path}` | 視頻文件完整路徑 | `/Users/accusys/momentry/videos/020.mp4` |
| `{output_path}` | 輸出 JSON 完整路徑 | `/Users/accusys/momentry/output/{uuid}.pose.json` |
| `{output_dir}` | 輸出目錄 | `/Users/accusys/momentry/output` |
| `{file_uuid}` | 視頻 UUID | `b496a68800f90770aa7246c877f38985` |
| `{face_json}` | face.json 路徑 | `/Users/accusys/momentry/output/{uuid}.face.json` |
---
## 環境變量
```bash
# 輸出目錄
export MOMENTRY_OUTPUT_DIR="/Users/accusys/momentry/output"
# Python 路徑
export MOMENTRY_PYTHON_PATH="/opt/homebrew/bin/python3.11"
# 腳本目錄
export MOMENTRY_SCRIPTS_DIR="tools/script/"
# CLI 工具目錄
export MOMENTRY_CLI_DIR="tools/cli/"
# 資料庫 Schema
export DATABASE_SCHEMA="public"
# 資料庫 URL
export DATABASE_URL="postgres://accusys@localhost:5432/momentry"
# Redis URL
export REDIS_URL="redis://:accusys@localhost:6379"
```
---
## 執行流程
### Worker 調用流程
1. **讀取配置**: `config/processor_tools_v3.json`
2. **選擇實現**: 根據 `priority` 和 `enabled` 選擇工具
3. **替換變量**: 將 `{variable}` 替換為實際值
4. **執行命令**: 使用 `std::process::Command` 執行
5. **監控超時**: 根據 `timeout` 設置超時
6. **檢查輸出**: 驗證 `output_file` 是否生成
---
## 錯誤處理
### 超時
```rust
// 設置超時
let timeout = Duration::from_secs(config.timeout.unwrap_or(3600));
// 執行命令
let output = Command::new(&executable)
.args(&args)
.timeout(timeout)
.output()?;
```
### 失敗重試
```rust
// 嘗試下一個 priority
if !success && next_implementation.priority < max_priority {
run_processor(next_implementation)?;
}
```
---
## 性能對比
| Processor | Python | Rust | Swift | 備註 |
|-----------|--------|------|-------|------|
| POSE | ~5s | ~2s | ~3s | Rust 最快 |
| FACE | ~8s | - | ~4s | Swift 優化 |
| ASR | ~30s | - | - | Whisper 主要耗時 |
| FACE_TRACE | ~2s | ~0.1s | - | **20x 速度提升** |
| CUT | ~3s | ~1s | - | Rust FFmpeg |
---
## 配置文件位置
- **V1 (舊)**: `config/processor_tools.json`
- **V2 (分離)**: `config/processor_tools_v2.json`
- **V3 (完整)**: `config/processor_tools_v3.json`
---
**更新日期**: 2026-09-27
**維護者**: Core Team