ffmpeg-chinese-subtitle

Windows 上使用 ffmpeg 正确生成中文字幕的解决方案。 用 Pillow 在图片上绘制字幕,ffmpeg 只负责图片转视频,完全避开编码问题。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "ffmpeg-chinese-subtitle" with this command: npx skills add systiger/ffmpeg-chinese-subtitle

ffmpeg Chinese Subtitle

Windows 上使用 ffmpeg 正确生成中文字幕的解决方案。

问题背景

在 Windows 上使用 ffmpeg 的 drawtextsubtitlesass 滤镜处理中文字幕时,会遇到以下问题:

错误码原因
返回码 -22 (EINVAL)字体路径转义问题
字幕不显示中文编码被截断
乱码字符集不匹配

解决方案

核心思路:用 Pillow 在图片上绘制字幕,ffmpeg 只负责图片转视频。

方案对比

方案状态原因
drawtext=text='中文'❌ 失败命令行参数截断
subtitles='中文.srt'❌ 失败路径编码问题
ass='中文.ass'❌ 失败同上
Pillow 绘制 + ffmpeg✅ 成功Python 原生支持 Unicode

快速使用

from ffmpeg_subtitle import add_subtitle_to_image

# 在图片上添加字幕
add_subtitle_to_image(
    image_path="input.png",
    subtitle_text="这是中文字幕",
    output_path="output.png",
    font_size=24,
    y_offset=50
)

参数说明

参数默认值说明
image_path-输入图片路径
subtitle_text-字幕文本
output_path-输出图片路径
font_size24字体大小
y_offset50距底部的偏移量(像素)
font_color(255,255,255)字体颜色 RGB
shadow_color(0,0,0)阴影颜色 RGB

依赖

Pillow>=10.0.0

字体

默认使用 Windows 系统字体:

  • 主字体:C:/Windows/Fonts/msyh.ttc(微软雅黑)
  • 备用字体:C:/Windows/Fonts/simhei.ttf(黑体)

触发词

ffmpeg字幕中文字幕视频字幕字幕烧录

文件结构

ffmpeg-chinese-subtitle/
├── SKILL.md           # 技能说明文档
├── README.md          # 详细使用指南
├── ffmpeg_subtitle.py # 核心模块
├── example.py         # 完整示例
└── package.json       # 包信息

License

MIT

Author

systiger

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

视频字幕自动生成器——免费的才是最好的

自动提取视频音频,识别生成带时间戳的文字稿,输出SRT/VTT字幕及带字幕的视频,并智能提炼视频标题。

Registry Source
2281Profile unavailable
General

Openclaw Cn Installer

OpenClaw 中文安装配置助手。一键检测环境、配置国产 AI 模型(DeepSeek/智谱/阿里通义)。适合中国用户快速上手 OpenClaw。

Registry SourceRecently Updated
2190Profile unavailable
General

Humanizer-zh (Elatia Enhanced)

去除文本中的 AI 生成痕迹。当用户说"润色"、"改写"、"去 AI 味"、"更像人写的"、 "不要太机械"、"自然一点"、"有人味"时使用。也用于:编辑邮件/文案/文章/报告、 审阅 AI 生成内容、优化写作风格、让文字不那么像机器生成的。基于维基百科"AI 写作特征"指南, 检测并修复:夸大象征、宣传语言、模...

Registry SourceRecently Updated
1.6K2Profile unavailable
General

Arch Video Cut

自动合并建筑视频,生成字幕和背景音乐,输出横屏与竖屏双版本,支持自学习优化剪辑偏好。

Registry SourceRecently Updated
2850Profile unavailable