媒體管線
本機 CPU 上的轉錄與 OCR 功能。使用 FFmpeg、faster-whisper (int8)、RapidOCR。Whisper 模型預設為 tiny。
佈局
路徑皆以 media-pipeline 檢出目錄為基準。
bin/mp 探測、處理、翻譯、列出、監控、自我測試、診斷
bin/mp-mcp stdio MCP 伺服器
inbox/ `mp watch` 監控的檔案
work/ 16 kHz wav 與 work/processed.json
outbox/<epoch>_<stem>/
normalized.mp4, thumbnail.jpg, transcript.txt,
transcript.srt, transcript.vtt, ocr.txt,
translation.<lang>.txt, manifest.json
failures/ `mp watch` 無法處理的輸入
install.sh 會將此技能複製到 $MP_SKILLS_DIR/media-pipeline(前提是該目錄已存在)。預設位置為 $HOME/.local/share/prime-agent/0.9.6/skills。
引擎
| 工作 | 引擎 | 備註 |
|---|---|---|
| 探測 | ffprobe | 格式、時長、串流 |
| 影片 | FFmpeg | H.264 + AAC,yuv420p,faststart,CRF 28;1 秒處縮圖,寬度 1280 |
| 模型用音訊 | FFmpeg | 16 kHz 單聲道 PCM,保留在 work/ 下 |
| 語音轉文字 | faster-whisper | CPU,MP_WHISPER_COMPUTE 預設 int8,模型 MP_WHISPER_MODEL 預設 tiny |
| 圖片文字 | RapidOCR | 透過 ONNX Runtime 執行 PP-OCRv4,寫入 ocr.txt |
| 翻譯 | Pollinations、Gemini 或 LiteLLM | 僅在要求時啟用;請參閱 references/engines.md |
指令
bin/mp selftest
bin/mp probe FILE
bin/mp process FILE
bin/mp process FILE --translate --target tr
bin/mp translate FILE --target tr
bin/mp watch
bin/mp doctor
process 會保留輸入檔案在原處。watch 會將其移動至 outbox/ 或 failures/。若檔案的 sha256 已存在於 work/processed.json 中,則會留在 inbox/。
doctor 在關鍵檢查失敗時會以退出碼 1 結束。其中一項檢查是 $HOME/bin/prime-tg,此儲存庫未包含該檔案。
MCP 工具
media_engines、media_probe、media_process、media_translate、media_batch。
media_process 接受 path、transcribe、ocr、translate 和 target_language 參數。media_batch 會處理 inbox/ 中的檔案,啟用轉錄與 OCR,關閉翻譯功能。
規則
- 將
MP_LITELLM_KEY和MP_GEMINI_KEY保留在環境變數中,請勿輸出它們。 tiny為預設模型。當錄音品質需要時,可將MP_WHISPER_MODEL設定為base或small。medium和large-v3是較大的下載檔。- 若
probe.duration_s為 0 且轉錄結果為空白,表示音訊未成功解碼。 - 若翻譯回傳錯誤,則文字不會被翻譯。請明確告知此情況。
- 儲存庫文字保留英文。
參考資料
references/engines.md:供應商順序、OCR 限制及 ARM 主機注意事項references/triggers.md:inbox 路徑單元與mp watchreferences/recipes.md:venv、ffmpeg 及 OCR 指令