媒体流水线
本机 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:收件箱路径单元和mp watch说明references/recipes.md:虚拟环境、ffmpeg 和 OCR 命令的详细教程