Files
momentry_playground/README.md

159 lines
3.9 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.
# MoMentry Playground
統一媒體播放、檢視、監控平台
## 功能
- 多格式媒體播放(視頻、音頻、圖片)
- Frame-精確的視頻控制
- **反向播放**`--start > --end --loop`
- ASR 字幕顯示(可開關)
- YOLO 檢測框疊加(可開關)
- Chunk 導航標記(可開關)
- Zoom/Pan 畫面控制
- 自然語言搜尋
- 與 momentry_core 進度監控
## 安裝依賴
```bash
# FFmpeg (必需)
brew install ffmpeg
# yt-dlp (YouTube 支援)
brew install yt-dlp
```
## 構建
```bash
cargo build --release
```
## 運行
```bash
# 基本運行
cargo run
# 開啟視頻
cargo run -- --video "/path/to/video.mov"
# 開啟視頻 + ASR 字幕
cargo run -- \
--video "/Users/accusys/test_video/Old_Time_Movie_Show_-_Charade_1963.HD.mov" \
--asr "/Users/accusys/momentry_core_0.1/output/39567a0eb16f39fd.asr.json" \
--yolo "/Users/accusys/test_video/Old_Time_Movie_Show_-_Charade_1963.HD.yolo.json"
# 反向播放 (從 130s 倒放到 120s循環)
cargo run -- \
--video "/Users/accusys/test_video/Old_Time_Movie_Show_-_Charade_1963.HD.mov" \
--start 130 --end 120 --loop
# 指定窗口大小
cargo run -- --width 1280 --height 720 --video video.mp4
```
## 快捷鍵
| 快捷鍵 | 功能 |
|--------|------|
| `Space` | 播放/暫停 |
| `←` / `→` | 上一幀/下一幀 |
| `Shift+←/→` | 後退/前進 1 秒 |
| `S` | 開關字幕 |
| `Y` | 開關 YOLO 疊加 |
| `C` | 開關 Chunk 標記 |
| `M` | 靜音 |
| `+` / `-` | 放大/縮小 |
| `0` | 重置縮放 |
| `R` | 重置視圖 |
| `F` | 全屏 |
| `[` / `]` | 上一塊/下一塊 |
| `/` | 開啟搜尋 |
| `H` | 快捷鍵幫助面板 |
| `<` / `>` | 減慢/加快播放速度 |
| `P` | 重置播放速度 |
| `E` | 匯出當前幀為 PNG |
| `Esc` | 關閉面板 |
## 命令列參數
```bash
-v, --video <PATH> 視頻文件路徑
-a, --asr <PATH> ASR JSON 文件路徑
-y, --yolo <PATH> YOLO JSON 文件路徑
-s, --start <SEC> 開始時間(秒)
-e, --end <SEC> 結束時間(秒)
--loop 循環播放
-w, --width <N> 窗口寬度 (default: 1280)
-h, --height <N> 窗口高度 (default: 720)
--fullscreen 全屏模式啟動
--locale <LANG> UI 語言 (en, zh-TW)
```
## 測試數據
```bash
VIDEO="/Users/accusys/test_video/Old_Time_Movie_Show_-_Charade_1963.HD.mov"
ASR="/Users/accusys/momentry_core_0.1/output/39567a0eb16f39fd.asr.json"
YOLO="/Users/accusys/test_video/Old_Time_Movie_Show_-_Charade_1963.HD.yolo.json"
```
## 開發
```bash
# 格式化
cargo fmt
# Lint
cargo clippy
# 測試
cargo test
```
## 技術棧
- **語言**: Rust 2021
- **桌面**: tao + wry
- **視頻**: SDL2 + FFmpeg
- **前端**: HTML/CSS/JS (WebView)
- **緩存**: LRU (YOLO frame cache)
## 服務連接
| 服務 | 地址 |
|------|------|
| PostgreSQL | localhost:5432 |
| Redis | localhost:6379 |
| Qdrant | localhost:6333 |
| API Server | 127.0.0.1:3002 |
| Ollama | localhost:11434 |
## 項目結構
```
momentry_playground/
├── Cargo.toml
├── src/
│ ├── main.rs # 入口
│ ├── lib.rs # 模組導出
│ ├── config.rs # 命令列解析
│ ├── player/ # 視頻播放
│ │ ├── video.rs # 播放控制
│ │ ├── ffmpeg.rs # FFmpeg 解碼
│ │ ├── renderer.rs # SDL2 渲染
│ │ └── state.rs # 播放狀態
│ ├── overlay/ # 疊加層
│ │ ├── asr.rs # ASR 載入
│ │ └── yolo.rs # YOLO 載入 (LRU cache)
│ └── web/ # WebView
│ └── bridge.rs # JS <-> Rust IPC
├── web/
│ ├── index.html # 主 UI
│ ├── styles.css # 樣式
│ └── app.js # 前端邏輯
└── AGENTS.md # 開發文檔
```