关于 omnicaptions-convert
omnicaptions-convert 是用于字幕工作流的技能,可在 30 多种格式间转换字幕文件。它还支持 ASS 样式设置,以及在具备逐词时间戳时生成卡拉 OK 字幕。
主要功能
- 01转换 30 多种字幕格式
- 02批量转换文件
- 03ASS 预设样式与自定义颜色
- 04逐词高亮卡拉 OK 字幕
适用场景
- 01将 SRT 转为 VTT、ASS 或 TTML
- 02将转录稿转换为标准字幕文件
- 03制作带样式或双语的 ASS 字幕
- 04从带逐词时间戳的 JSON 生成卡拉 OK 字幕
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ lattifai/ omni-captions-skills --skill omnicaptions-convert安装后在 Claude Code 中输入/omnicaptions-convert确认已加载。
详细介绍
字幕格式转换
使用 lattifai-captions 在 30 多种字幕格式之间进行转换。
⚡ YouTube 工作流
# 1. Transcribe YouTube video directly
omnicaptions transcribe "https://youtube.com/watch?v=VIDEO_ID" -o transcript.md
# 2. Convert to any format
omnicaptions convert transcript.md -o output.srt
omnicaptions convert transcript.md -o output.ass
omnicaptions convert transcript.md -o output.vtt
适用场景
- 将 SRT 转换为 VTT、ASS、TTML 等格式
- 将 Gemini markdown 转录稿转换为标准字幕格式
- 将带有单词级时间戳的 YouTube VTT 转换为其他格式
- 批量格式转换
不适用场景
- 需要转录(使用
/omnicaptions:transcribe) - 需要翻译(使用
/omnicaptions:translate)
设置
pip install omni-captions-skills --extra-index-url https://lattifai.github.io/pypi/simple/
快速参考
| 格式 | 扩展名 | 读取 | 写入 |
|---|---|---|---|
| SRT | .srt | ✓ | ✓ |
| VTT | .vtt | ✓ | ✓ |
| ASS/SSA | .ass | ✓ | ✓ |
| TTML | .ttml | ✓ | ✓ |
| Gemini MD | .md | ✓ | ✓ |
| JSON | .json | ✓ | ✓ |
| TXT | .txt | ✓ | ✓ |
完整列表:SRT、VTT、ASS、SSA、TTML、DFXP、SBV、SUB、LRC、JSON、TXT、TSV、Audacity、Audition、FCPXML、EDL 等。
CLI 用法
# Convert (auto-output to same directory, only changes extension)
omnicaptions convert input.srt -t vtt # → ./input.vtt
omnicaptions convert transcript.md # → ./transcript.srt
# Specify output file or directory
omnicaptions convert input.srt -o output/ # → output/input.srt
omnicaptions convert input.srt -o output.vtt # → output.vtt
# Specify format explicitly
omnicaptions convert input.txt -o out.srt -f txt -t srt
ASS 样式预设
转换为 ASS 格式时,使用 --style 应用预设样式:
omnicaptions convert input.srt -o output.ass --style default # White text, bottom
omnicaptions convert input.srt -o output.ass --style top # White text, top
omnicaptions convert input.srt -o output.ass --style bilingual # White + Yellow (for bilingual)
omnicaptions convert input.srt -o output.ass --style yellow # Yellow text, bottom
| 预设 | 位置 | 第 1 行 | 第 2 行 | 用途 |
|---|---|---|---|---|
default | 底部 | 白色 | 白色 | 标准字幕 |
top | 顶部 | 白色 | 白色 | 底部被占用时 |
bilingual | 底部 | 白色 | 黄色 | 双语字幕(原文 + 译文) |
yellow | 底部 | 黄色 | 黄色 | 高可见度 |
双语示例
如果你的 SRT 包含如下双行字幕:
1
00:00:01,000 --> 00:00:03,000
Hello World
你好世界
使用 --style bilingual 或自定义颜色:
# Preset: white + yellow
omnicaptions convert bilingual.srt -o output.ass --style bilingual
# Custom colors: green English + yellow Chinese
omnicaptions convert bilingual.srt -o output.ass --line1-color "#00FF00" --line2-color "#FFFF00"
# Mix preset with custom line2 color
omnicaptions convert bilingual.srt -o output.ass --style default --line2-color "#FF6600"
自定义颜色选项
| 选项 | 说明 |
|---|---|
--line1-color "#RRGGBB" | 第一行(原文)的颜色 |
--line2-color "#RRGGBB" | 第二行(译文)的颜色 |
常见颜色:#FFFFFF(白色)、#FFFF00(黄色)、#00FF00(绿色)、#00FFFF(青色)、#FF6600(橙色)
字体大小与分辨率
字体大小会根据视频分辨率自动计算。分辨率按以下优先级检测:
--resolution参数(例如1080p、4k、1920x1080)--video参数(使用 ffprobe 检测).meta.json文件(由omnicaptions download保存)- 默认值:1080p
# Auto-detect from .meta.json (saved by download command)
omnicaptions convert abc123.en.srt -o abc123.en.ass --karaoke
# Specify resolution directly
omnicaptions convert input.srt -o output.ass --resolution 4k
omnicaptions convert input.srt -o output.ass --resolution 720p
omnicaptions convert input.srt -o output.ass --resolution 1920x1080
# Detect from video file (uses ffprobe)
omnicaptions convert input.srt -o output.ass --video video.mp4
# Override auto-calculated fontsize
omnicaptions convert input.srt -o output.ass --resolution 4k --fontsize 80
| 分辨率 | PlayRes | 自动字体大小 |
|---|---|---|
| 480p | 854×480 | 24 |
| 720p | 1280×720 | 32 |
| 1080p | 1920×1080 | 48(默认) |
| 2K | 2560×1440 | 64 |
| 4K | 3840×2160 | 96 |
卡拉 OK 模式
生成带有单词级高亮效果的卡拉 OK 字幕。需要单词级时间信息(请先使用 LaiCut 对齐)。
# Basic karaoke (sweep effect - gradual fill)
omnicaptions convert lyrics_LaiCut.json -o lyrics_LaiCut_karaoke.ass --karaoke
# Different effects
omnicaptions convert lyrics_LaiCut.json -o lyrics_LaiCut_karaoke.ass --karaoke sweep # Gradual fill (default)
omnicaptions convert lyrics_LaiCut.json -o lyrics_LaiCut_karaoke.ass --karaoke instant # Instant highlight
omnicaptions convert lyrics_LaiCut.json -o lyrics_LaiCut_karaoke.ass --karaoke outline # Outline then fill
# LRC karaoke (enhanced word timestamps)
omnicaptions convert lyrics_LaiCut.json -o lyrics_LaiCut_karaoke.lrc --karaoke
| 效果 | ASS 标签 | 说明 |
|---|---|---|
sweep | \kf | 从左向右逐渐填充(默认) |
instant | \k | 即时高亮单词 |
outline | \ko | 先填充轮廓,再填充文字 |
卡拉 OK 工作流
# 1. Align with LaiCut (get word-level timing in JSON)
omnicaptions LaiCut audio.mp3 lyrics.txt
# 2. Convert to karaoke ASS
omnicaptions convert lyrics_LaiCut.json -o karaoke.ass --karaoke
# Or combine with style
omnicaptions convert lyrics_LaiCut.json -o karaoke.ass --karaoke --style yellow
Python 用法
from omnicaptions import Caption
# Load any format
cap = Caption.read("input.srt")
# Write to any format
cap.write("output.vtt")
cap.write("output.ass")
cap.write("output.ttml")
常见错误
| 错误 | 解决方法 |
|---|---|
| 未检测到格式 | 使用 --from / --to 标志 |
| 缺少时间戳 | 源格式必须包含时间信息 |
| 编码错误 | 指定 encoding="utf-8" |
相关技能
| 技能 | 使用场景 |
|---|---|
/omnicaptions:transcribe | 需要从音频/视频生成转录稿 |
/omnicaptions:translate | 使用 Gemini API 翻译 |
/omnicaptions:translate | 使用 Claude 翻译(无需 API 密钥) |
/omnicaptions:download | 先下载视频/字幕 |
工作流示例
# Transcribe → Convert → Translate (with Claude)
/omnicaptions:transcribe video.mp4
/omnicaptions:convert video_GeminiUnd.md -o video.srt
/omnicaptions:translate video.srt -l zh --bilingual
评论
支持 Markdown