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
+312
View File
@@ -0,0 +1,312 @@
{
"processor_config": {
"pose": {
"implementations": [
{
"tool": "python",
"model": "mediapipe",
"priority": 0,
"enabled": true,
"parameters": {
"model_complexity": 2,
"min_confidence": 0.5,
"script": "pose_processor_mediapipe.py"
}
},
{
"tool": "rust",
"model": null,
"priority": 1,
"enabled": true,
"parameters": {},
"binary": "rust_pose"
},
{
"tool": "swift",
"model": null,
"priority": 2,
"enabled": true,
"parameters": {},
"binary": "swift_pose"
},
{
"tool": "python",
"model": "yolov8-pose",
"priority": 3,
"enabled": false,
"parameters": {
"model_file": "yolov8n-pose.pt"
}
}
],
"default": {
"tool": "python",
"model": "mediapipe"
},
"timeout": 3600,
"enabled": true
},
"face": {
"implementations": [
{
"tool": "swift",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {},
"binary": "swift_face"
},
{
"tool": "python",
"model": null,
"priority": 1,
"enabled": true,
"parameters": {},
"script": "face_detector.py"
}
],
"default": {
"tool": "swift",
"model": null
},
"enabled": true
},
"asr": {
"implementations": [
{
"tool": "python",
"model": "whisper",
"priority": 0,
"enabled": true,
"parameters": {
"model_size": "large-v3",
"model_dir": "/Users/accusys/models/whisper-small-mlx",
"script": "asr_processor_whisper.py"
}
},
{
"tool": "rust",
"model": "whisper",
"priority": 1,
"enabled": false,
"parameters": {
"model_size": "base"
}
}
],
"default": {
"tool": "python",
"model": "whisper"
},
"enabled": true
},
"asrx": {
"implementations": [
{
"tool": "swift",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {},
"binary": "swift_asrx"
},
{
"tool": "python",
"model": null,
"priority": 1,
"enabled": true,
"parameters": {},
"script": "asrx_processor.py"
}
],
"default": {
"tool": "swift",
"model": null
},
"enabled": true
},
"ocr": {
"implementations": [
{
"tool": "swift",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {},
"binary": "swift_ocr"
},
{
"tool": "python",
"model": "tesseract",
"priority": 1,
"enabled": true,
"parameters": {},
"script": "ocr_processor.py"
}
],
"default": {
"tool": "swift",
"model": null
},
"enabled": true
},
"face_trace": {
"implementations": [
{
"tool": "rust",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {
"min_trace_len": 0,
"min_confidence": 0.0
},
"binary": "rust_store_traced_faces"
},
{
"tool": "python",
"model": null,
"priority": 1,
"enabled": false,
"parameters": {},
"script": "store_traced_faces.py"
}
],
"default": {
"tool": "rust",
"model": null
},
"enabled": true
},
"face_deduplicate": {
"implementations": [
{
"tool": "python",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {},
"script": "face_deduplicate.py"
},
{
"tool": "rust",
"model": null,
"priority": 1,
"enabled": false,
"parameters": {},
"binary": "rust_face_deduplicate"
}
],
"default": {
"tool": "python",
"model": null
},
"enabled": true
},
"scene_vlm_summary": {
"implementations": [
{
"tool": "python",
"model": "gemma-4-12b-it",
"priority": 0,
"enabled": true,
"parameters": {
"max_tokens": 300,
"llm_url": "http://localhost:8080/v1/chat/completions",
"script": "scene_vlm_summary.py"
}
}
],
"default": {
"tool": "python",
"model": "gemma-4-12b-it"
},
"enabled": true
},
"tkg": {
"implementations": [
{
"tool": "python",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {},
"script": "build_tkg.py"
},
{
"tool": "rust",
"model": null,
"priority": 1,
"enabled": false,
"parameters": {},
"binary": "rust_tkg"
}
],
"default": {
"tool": "python",
"model": null
},
"enabled": true
},
"vlm_summary": {
"implementations": [
{
"tool": "rust",
"model": "gemma-4-12b-it",
"priority": 0,
"enabled": true,
"parameters": {
"max_tokens": 800,
"use_vision": true,
"llm_url": "http://localhost:8080/v1/chat/completions"
},
"binary": "rust_vlm_summary"
}
],
"default": {
"tool": "rust",
"model": "gemma-4-12b-it"
},
"enabled": true
},
"cut": {
"implementations": [
{
"tool": "rust",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {
"use_ffmpeg": true,
"min_scene_duration": 0.5
},
"binary": "rust_cut"
},
{
"tool": "python",
"model": null,
"priority": 1,
"enabled": false,
"parameters": {},
"script": "cut_detector.py"
}
],
"default": {
"tool": "rust",
"model": null
},
"enabled": true
}
},
"metadata": {
"version": "2.0",
"description": "Processor configuration with tool/model separation",
"tools": ["python", "rust", "swift"],
"models": {
"whisper": ["base", "small", "medium", "large", "large-v3"],
"mediapipe": ["pose", "face"],
"yolov8": ["pose", "detect"],
"gemma": ["gemma-4-12b-it", "embeddinggemma-300m"]
}
}
}
+448
View File
@@ -0,0 +1,448 @@
{
"processor_config": {
"pose": {
"implementations": [
{
"tool": "python",
"model": "mediapipe",
"priority": 0,
"enabled": true,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/pose_processor_mediapipe.py",
"args": [
"{video_path}",
"{output_path}",
"--uuid", "{file_uuid}",
"--model-complexity", "{model_complexity}"
]
},
"parameters": {
"model_complexity": 2,
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task"
},
"output_file": "{file_uuid}.pose.json",
"timeout": 3600
},
{
"tool": "rust",
"model": null,
"priority": 1,
"enabled": true,
"command": {
"executable": "tools/cli/rust/target/release/rust_pose",
"args": [
"--video", "{video_path}",
"--output", "{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.pose.json",
"timeout": 1800
},
{
"tool": "swift",
"model": null,
"priority": 2,
"enabled": true,
"command": {
"executable": "tools/cli/swift/.build/release/swift_pose",
"args": [
"{video_path}",
"--output", "{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.pose.json",
"timeout": 1800
},
{
"tool": "python",
"model": "yolov8-pose",
"priority": 3,
"enabled": false,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/pose_processor_yolov8.py",
"args": [
"{video_path}",
"{output_path}",
"--model", "{model_file}"
]
},
"parameters": {
"model_file": "yolov8n-pose.pt"
},
"output_file": "{file_uuid}.pose.json",
"timeout": 3600
}
],
"default": {
"tool": "python",
"model": "mediapipe"
}
},
"face": {
"implementations": [
{
"tool": "swift",
"model": null,
"priority": 0,
"enabled": true,
"command": {
"executable": "tools/cli/swift/.build/release/swift_face",
"args": [
"{video_path}",
"--output", "{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.face.json",
"timeout": 3600
},
{
"tool": "python",
"model": "facenet",
"priority": 1,
"enabled": true,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/face_detector.py",
"args": [
"{video_path}",
"{output_path}",
"--uuid", "{file_uuid}",
"--model", "{model_name}"
]
},
"parameters": {
"model_name": "facenet",
"model_path": "/Users/accusys/models/facenet512.mlpackage"
},
"output_file": "{file_uuid}.face.json",
"timeout": 3600
}
],
"default": {
"tool": "swift",
"model": null
}
},
"asr": {
"implementations": [
{
"tool": "python",
"model": "whisper",
"priority": 0,
"enabled": true,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/asr_processor_simplified.py",
"args": [
"{video_path}",
"{output_path}",
"--model", "{model_size}"
]
},
"parameters": {
"model_size": "large-v3",
"model_dir": "/Users/accusys/models/whisper-small-mlx"
},
"output_file": "{file_uuid}.asr.json",
"timeout": 7200
}
],
"default": {
"tool": "python",
"model": "whisper"
}
},
"asrx": {
"implementations": [
{
"tool": "swift",
"model": null,
"priority": 0,
"enabled": true,
"command": {
"executable": "tools/cli/swift/.build/release/swift_asrx",
"args": [
"{video_path}",
"--output", "{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.asrx.json",
"timeout": 1800
},
{
"tool": "python",
"model": null,
"priority": 1,
"enabled": true,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/asrx_processor.py",
"args": [
"{video_path}",
"{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.asrx.json",
"timeout": 1800
}
],
"default": {
"tool": "swift",
"model": null
}
},
"ocr": {
"implementations": [
{
"tool": "swift",
"model": null,
"priority": 0,
"enabled": true,
"command": {
"executable": "tools/cli/swift/.build/release/swift_ocr",
"args": [
"{video_path}",
"--output", "{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.ocr.json",
"timeout": 3600
},
{
"tool": "python",
"model": "tesseract",
"priority": 1,
"enabled": true,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/ocr_processor.py",
"args": [
"{video_path}",
"{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.ocr.json",
"timeout": 3600
}
],
"default": {
"tool": "swift",
"model": null
}
},
"face_trace": {
"implementations": [
{
"tool": "rust",
"model": null,
"priority": 0,
"enabled": true,
"command": {
"executable": "tools/cli/rust/target/release/rust_store_traced_faces",
"args": [
"{file_uuid}",
"--output-dir", "{output_dir}",
"--min-trace-len", "{min_trace_len}",
"--min-confidence", "{min_confidence}"
]
},
"parameters": {
"min_trace_len": 0,
"min_confidence": 0.0
},
"output_file": "{file_uuid}.face_traced.json",
"timeout": 600
},
{
"tool": "python",
"model": null,
"priority": 1,
"enabled": false,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/store_traced_faces.py",
"args": [
"--file-uuid", "{file_uuid}",
"--face-json", "{face_json}"
]
},
"parameters": {},
"output_file": "{file_uuid}.face_traced.json",
"timeout": 1200
}
],
"default": {
"tool": "rust",
"model": null
}
},
"scene_vlm_summary": {
"implementations": [
{
"tool": "python",
"model": "gemma-4-12b-it",
"priority": 0,
"enabled": true,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/scene_vlm_summary.py",
"args": [
"--file-uuid", "{file_uuid}",
"--output-dir", "{output_dir}",
"--llm-url", "{llm_url}",
"--max-tokens", "{max_tokens}"
]
},
"parameters": {
"llm_url": "http://localhost:8080/v1/chat/completions",
"max_tokens": 300
},
"output_file": "{file_uuid}.scene_vlm.json",
"timeout": 1800
}
],
"default": {
"tool": "python",
"model": "gemma-4-12b-it"
}
},
"tkg": {
"implementations": [
{
"tool": "python",
"model": null,
"priority": 0,
"enabled": true,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/build_tkg.py",
"args": [
"--file-uuid", "{file_uuid}",
"--output-dir", "{output_dir}"
]
},
"parameters": {},
"output_file": "{file_uuid}.tkg.json",
"timeout": 1800
}
],
"default": {
"tool": "python",
"model": null
}
},
"cut": {
"implementations": [
{
"tool": "rust",
"model": null,
"priority": 0,
"enabled": true,
"command": {
"executable": "tools/cli/rust/target/release/rust_cut",
"args": [
"{video_path}",
"--output", "{output_path}",
"--uuid", "{file_uuid}",
"--min-scene-duration", "{min_scene_duration}"
]
},
"parameters": {
"use_ffmpeg": true,
"min_scene_duration": 0.5
},
"output_file": "{file_uuid}.cut.json",
"timeout": 1800
},
{
"tool": "python",
"model": null,
"priority": 1,
"enabled": false,
"command": {
"executable": "/opt/homebrew/bin/python3.11",
"script": "scripts/cut_detector.py",
"args": [
"{video_path}",
"{output_path}",
"--uuid", "{file_uuid}"
]
},
"parameters": {},
"output_file": "{file_uuid}.cut.json",
"timeout": 1800
}
],
"default": {
"tool": "rust",
"model": null
}
}
},
"variables": {
"video_path": "Full path to video file",
"output_path": "Full path to output JSON file",
"output_dir": "Output directory (default: /Users/accusys/momentry/output)",
"file_uuid": "Video file UUID",
"face_json": "Path to face.json file"
},
"environment": {
"MOMENTRY_OUTPUT_DIR": "/Users/accusys/momentry/output",
"MOMENTRY_SCRIPTS_DIR": "tools/script/",
"MOMENTRY_CLI_DIR": "tools/cli/",
"MOMENTRY_PYTHON_PATH": "/opt/homebrew/bin/python3.11",
"DATABASE_SCHEMA": "public",
"DATABASE_URL": "postgres://accusys@localhost:5432/momentry",
"REDIS_URL": "redis://:accusys@localhost:6379"
},
"models": {
"whisper": {
"description": "OpenAI Whisper ASR model",
"sizes": ["tiny", "base", "small", "medium", "large", "large-v3"],
"default_size": "large-v3",
"model_dir": "/Users/accusys/models/whisper-small-mlx"
},
"mediapipe": {
"description": "MediaPipe Pose estimation",
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task",
"complexity_levels": [0, 1, 2],
"default_complexity": 2
},
"facenet": {
"description": "FaceNet 512D embedding model",
"model_path": "/Users/accusys/models/facenet512.mlpackage"
},
"gemma-4-12b-it": {
"description": "Gemma 4 12B instruct model for VLM/LLM",
"model_path": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf",
"mmproj_path": "/Users/accusys/models/mmproj-F16.gguf",
"llm_url": "http://localhost:8080/v1/chat/completions"
},
"embeddinggemma-300m": {
"description": "Embedding Gemma 300M for vector embeddings",
"model_path": "/Users/accusys/models/embeddinggemma-300M-Q8_0.gguf",
"embedding_url": "http://localhost:11436/embed"
}
},
"metadata": {
"version": "3.0",
"description": "Processor configuration with full command and parameters",
"last_updated": "2026-09-27"
}
}
@@ -0,0 +1,370 @@
---
title: Processor Configuration V2 Design
version: 2.0
date: 2026-09-27
author: OpenCode
status: draft
---
## 背景
當前配置結構混淆了 tool 和 model 的概念。
---
## 問題分析
### 舊格式 (V1)
```json
{
"pose": {
"tools": [
{
"name": "mediapipe", // ❌ 是 model 還是 tool?
"priority": 0,
"enabled": true,
"parameters": {...}
},
{
"name": "rust", // ❌ 是 tool,沒有 model 信息
"priority": 1
}
]
}
}
```
**問題**:
- `name` 混合了 tool 和 model
- 沒有明確區分實現方式和模型
- 難以追蹤使用了哪個模型
---
## 新格式 (V2)
```json
{
"pose": {
"implementations": [
{
"tool": "python", // ✅ 明確是 Python 實現
"model": "mediapipe", // ✅ 明確使用 MediaPipe 模型
"priority": 0,
"enabled": true,
"parameters": {...},
"script": "pose_processor_mediapipe.py" // ✅ 明確指定腳本
},
{
"tool": "rust", // ✅ 明確是 Rust 實現
"model": null, // ✅ 沒有特定模型
"priority": 1,
"enabled": true,
"parameters": {},
"binary": "rust_pose" // ✅ 明確指定二進制
}
],
"default": {
"tool": "python",
"model": "mediapipe"
}
}
}
```
---
## 結構說明
### Processor 配置
```typescript
interface ProcessorConfig {
implementations: Implementation[];
default: {
tool: Tool;
model: Model | null;
};
timeout?: number;
enabled: boolean;
}
```
### Implementation
```typescript
interface Implementation {
tool: "python" | "rust" | "swift";
model: Model | null;
priority: number;
enabled: boolean;
parameters: Record<string, any>;
// Tool-specific fields
script?: string; // for Python
binary?: string; // for Rust/Swift
}
```
### Model
```typescript
type Model =
| "whisper"
| "mediapipe"
| "yolov8-pose"
| "gemma-4-12b-it"
| "tesseract"
| null;
```
---
## 配置示例
### ASR (使用 Whisper)
```json
{
"asr": {
"implementations": [
{
"tool": "python",
"model": "whisper",
"priority": 0,
"enabled": true,
"parameters": {
"model_size": "large-v3",
"model_dir": "/Users/accusys/models/whisper-small-mlx"
},
"script": "asr_processor_whisper.py"
}
],
"default": {
"tool": "python",
"model": "whisper"
}
}
}
```
### Face Trace (Rust 實現)
```json
{
"face_trace": {
"implementations": [
{
"tool": "rust",
"model": null,
"priority": 0,
"enabled": true,
"parameters": {
"min_trace_len": 0,
"min_confidence": 0.0
},
"binary": "rust_store_traced_faces"
}
],
"default": {
"tool": "rust",
"model": null
}
}
}
```
### VLM Summary (使用 Gemma4)
```json
{
"vlm_summary": {
"implementations": [
{
"tool": "rust",
"model": "gemma-4-12b-it",
"priority": 0,
"enabled": true,
"parameters": {
"max_tokens": 800,
"use_vision": true,
"llm_url": "http://localhost:8080/v1/chat/completions"
},
"binary": "rust_vlm_summary"
}
],
"default": {
"tool": "rust",
"model": "gemma-4-12b-it"
}
}
}
```
---
## Tool 映射
### Python
| Processor | Script | Model |
|-----------|--------|-------|
| pose | `pose_processor_mediapipe.py` | mediapipe |
| face | `face_detector.py` | - |
| asr | `asr_processor_whisper.py` | whisper |
| face_trace | `store_traced_faces.py` | - |
| tkg | `build_tkg.py` | - |
### Rust
| Processor | Binary | Model |
|-----------|--------|-------|
| pose | `rust_pose` | - |
| face_trace | `rust_store_traced_faces` | - |
| vlm_summary | `rust_vlm_summary` | gemma-4-12b-it |
| cut | `rust_cut` | - |
### Swift
| Processor | Binary | Model |
|-----------|--------|-------|
| pose | `swift_pose` | - |
| face | `swift_face` | - |
| asrx | `swift_asrx` | - |
| ocr | `swift_ocr` | - |
---
## Model 參數
### Whisper
```json
{
"model_size": "large-v3",
"model_dir": "/path/to/models",
"language": "auto",
"task": "transcribe"
}
```
### MediaPipe
```json
{
"model_complexity": 2,
"min_confidence": 0.5,
"model_path": "/path/to/pose_landmarker_heavy.task"
}
```
### Gemma4
```json
{
"max_tokens": 800,
"use_vision": true,
"llm_url": "http://localhost:8080/v1/chat/completions"
}
```
---
## 遷移計劃
### Phase 1: 並行運行
- 保留舊格式 `processor_tools.json`
- 新增新格式 `processor_tools_v2.json`
- 更新 `ToolSelector` 支持兩種格式
### Phase 2: 全面遷移
- 更新所有配置為新格式
- 移除舊格式支持
- 更新文檔
### Phase 3: 增強功能
- 支持動態模型選擇
- 支持模型性能監控
- 支持自動降級
---
## Rust 結構體更新
### V1 (當前)
```rust
struct ToolConfig {
name: String,
priority: u8,
enabled: bool,
parameters: HashMap<String, Value>,
}
struct ProcessorConfig {
tools: Vec<ToolConfig>,
default_tool: String,
enabled: bool,
}
```
### V2 (新版)
```rust
struct Implementation {
tool: Tool,
model: Option<Model>,
priority: u8,
enabled: bool,
parameters: HashMap<String, Value>,
script: Option<String>,
binary: Option<String>,
}
struct ProcessorConfigV2 {
implementations: Vec<Implementation>,
default: DefaultConfig,
timeout: Option<u64>,
enabled: bool,
}
enum Tool {
Python,
Rust,
Swift,
}
enum Model {
Whisper,
MediaPipe,
YoloV8Pose,
Gemma4,
Tesseract,
}
```
---
## 優勢
1. **清晰性**: tool 和 model 明確分離
2. **可追蹤性**: 知道使用了哪個模型
3. **靈活性**: 支持多個實現版本
4. **可擴展性**: 易於添加新工具和模型
---
## 文件位置
- **舊格式**: `config/processor_tools.json`
- **新格式**: `config/processor_tools_v2.json`
- **合併格式**: `config/admin_config.json` (待更新)
---
**狀態**: 📝 草稿
**下一步**: 更新 Rust 代碼支持 V2 格式
@@ -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