返回顶部
f

ffmpeg-chinese-subtitle

|

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
86
下载量
0
收藏
概述
安装方式
版本历史

ffmpeg-chinese-subtitle

# ffmpeg Chinese Subtitle Windows 上使用 ffmpeg 正确生成中文字幕的解决方案。 ## 问题背景 在 Windows 上使用 ffmpeg 的 `drawtext`、`subtitles`、`ass` 滤镜处理中文字幕时,会遇到以下问题: | 错误码 | 原因 | |--------|------| | 返回码 -22 (EINVAL) | 字体路径转义问题 | | 字幕不显示 | 中文编码被截断 | | 乱码 | 字符集不匹配 | ## 解决方案 **核心思路**:用 Pillow 在图片上绘制字幕,ffmpeg 只负责图片转视频。 ### 方案对比 | 方案 | 状态 | 原因 | |------|------|------| | `drawtext=text='中文'` | ❌ 失败 | 命令行参数截断 | | `subtitles='中文.srt'` | ❌ 失败 | 路径编码问题 | | `ass='中文.ass'` | ❌ 失败 | 同上 | | **Pillow 绘制 + ffmpeg** | ✅ 成功 | Python 原生支持 Unicode | ## 快速使用 ```python 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_size` | 24 | 字体大小 | | `y_offset` | 50 | 距底部的偏移量(像素) | | `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

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 ffmpeg-chinese-subtitle-1776025117 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 ffmpeg-chinese-subtitle-1776025117 技能

通过命令行安装

skillhub install ffmpeg-chinese-subtitle-1776025117

下载 Zip 包

⬇ 下载 ffmpeg-chinese-subtitle v1.0.0

文件大小: 7.37 KB | 发布时间: 2026-4-13 10:17

v1.0.0 最新 2026-4-13 10:17
- Initial release: provides a solution for generating Chinese subtitles on Windows with ffmpeg.
- Uses Pillow to render subtitles onto images, avoiding ffmpeg text encoding issues.
- Supports custom font, font size, color, and positioning options.
- Simple API for adding Chinese subtitles to images for further video processing.
- Includes detailed usage instructions and dependency information.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部