
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
auto-video-generator
Advanced tools
一个基于Python的自动化视频生成工具,支持文字转语音、字幕同步和视频合成。
video4/
├── auto_generate_video.py # 主程序入口
├── test_auto_split.py # 智能分割测试脚本
├── build_exe.py # exe打包脚本
├── config.json # 配置文件
├── simhei.ttf # 字体文件
├── ffmpeg/ # FFmpeg工具包
│ └── bin/
│ ├── ffmpeg.exe
│ ├── ffprobe.exe
│ └── ffplay.exe
├── 发布版/ # 发布包
│ ├── auto_generate_video.exe
│ ├── config.json
│ └── README.md
└── output1.mp4 # 输出视频文件
pip install -r requirements.txt
编辑 config.json
文件,设置字幕内容和样式:
{
"video": "test.mp4",
"output": "output1.mp4",
"activeTimbre": 0,
"autoSplit": {
"enable": true,
"strategy": "smart",
"maxChars": 20,
"targetDuration": 3.0
},
"timing": [
{
"text": "欢迎使用自动生成带字幕视频工具!这是一个很长的句子,需要被智能分割。"
},
{
"text": "第一步:解压发布包,确保目录结构完整。第二步:找到README文件。"
}
],
"segments": [
{"start": "00:00:00", "end": "00:00:11"},
{"start": "00:01:26", "end": "00:01:50"}
],
"subtitleStyle": {
"fontPath": "./simhei.ttf",
"fontSize": 40,
"color": "white",
"bgColor": [0, 0, 0, 128],
"marginX": 100,
"marginBottom": 50,
"height": 100
}
}
python auto_generate_video.py
下载 发布版
目录中的所有文件
auto_generate_video.exe
config.json
配置文件output1.mp4
文件智能分割功能可以自动将长字幕分割成更短的片段,提高字幕的可读性和观看体验。
{
"autoSplit": {
"enable": true, // 是否启用智能分割
"strategy": "smart", // 分割策略: "smart", "duration", "none"
"maxChars": 20, // 最大字符数(仅smart策略有效)
"targetDuration": 3.0 // 目标时长(仅duration策略有效)
}
}
{
"autoSplit": {
"enable": true,
"strategy": "smart",
"maxChars": 15
},
"timing": [
{"text": "欢迎使用自动生成带字幕视频工具!这是一个很长的句子,需要被智能分割。"}
]
}
分割结果:
{
"autoSplit": {
"enable": true,
"strategy": "duration",
"targetDuration": 3.0
},
"timing": [
{"text": "欢迎使用自动生成带字幕视频工具!", "duration": 2.5},
{"text": "第一步:解压发布包,确保目录结构完整。", "duration": 3.0},
{"text": "第二步:找到README文件,可以看到参数说明。", "duration": 2.8}
]
}
分割结果:
segmentsMode
: 控制segments字段的含义
"keep"
: 保留模式 - segments指定要保留的片段"cut"
: 剪掉模式 - segments指定要剪掉的片段{
"segmentsMode": "keep",
"segments": [
{"start": "00:00:10", "end": "00:00:20"},
{"start": "00:00:40", "end": "00:00:50"}
]
}
表示保留1020秒和4050秒,最终视频为这两个片段的拼接(总时长20秒)。
{
"segmentsMode": "cut",
"segments": [
{"start": "00:00:10", "end": "00:00:20"},
{"start": "00:00:40", "end": "00:00:50"}
]
}
表示剪掉1020秒和4050秒,最终视频为010、2040、50~结尾的拼接。
python build_exe.py
{
"video": "test.mp4",
"output": "output1.mp4",
"activeTimbre": 0,
"autoSplit": {
"enable": true,
"strategy": "smart",
"maxChars": 20,
"targetDuration": 3.0
},
"timing": [
{
"text": "欢迎使用自动生成带字幕视频工具!"
},
{
"text": "这是一个功能强大的工具"
}
],
"segments": [
{"start": "00:00:00", "end": "00:00:11"}
],
"subtitleStyle": {
"fontPath": "./simhei.ttf",
"fontSize": 40,
"color": "white",
"bgColor": [0, 0, 0, 128],
"marginX": 100,
"marginBottom": 50,
"height": 100
}
}
config.json
配置文件程序会根据 activeTimbre
索引自动选择对应的音色。常用的音色索引:
delay
字段控制每条字幕的播放延迟通过 subtitleStyle
字段可以自定义字幕外观:
{
"subtitleStyle": {
"fontPath": "./simhei.ttf", // 字体文件
"fontSize": 40, // 字体大小
"color": "white", // 字体颜色
"bgColor": [0, 0, 0, 128], // 背景颜色 [R, G, B, A]
"marginX": 100, // 水平边距
"marginBottom": 50, // 底部边距
"height": 100 // 字幕高度
}
}
运行测试脚本验证智能分割功能:
python test_auto_split.py
测试脚本会显示:
simhei.ttf
字体文件存在于项目目录字体文件缺失
simhei.ttf
文件存在fontPath
配置是否正确智能分割效果不理想
maxChars
参数strategy
策略视频文件找不到
音频生成失败
exe文件运行缓慢
本项目采用 MIT 许可证,详见 LICENSE 文件。
欢迎提交 Issue 和 Pull Request 来改进这个项目。
如有问题或建议,请通过以下方式联系:
注意: 本项目仅供学习和研究使用,请遵守相关法律法规。
"timing": [
{
"text": "欢迎使用自动生成带字幕视频工具!第一步:解压发布包,确保目录结构完整。第二步:找到README文件,可以看到参数说明。第三步:你可以在 config.json 中自定义字幕内容、音色、视频片段等。修改 timing 字段可更换每条字幕和语音内容。修改 segments 字段可自定义需要剪掉的视频片段。修改 subtitleStyle 可自定义字幕样式。全部设置完成后,运行 exe 即可自动生成带字幕的视频。输出文件 output1.mp4 会在同目录下生成。如遇到问题,请查阅 README.md 或联系开发者。感谢使用,祝你创作愉快!"
}
]
{"text": " ", "delay": 1000}
(delay单位为毫秒)"timing": [
{"text": " ", "delay": 1000}, // 开头静默1秒
{"text": "这是第一条字幕"},
{"text": " ", "delay": 500}, // 中间静默0.5秒
{"text": "这是第二条字幕"},
{"text": " ", "delay": 2000} // 结尾静默2秒
]
视频时长: 20.00 秒
音频时长: 52.06 秒
音频时长超过视频时长,将音频截断至 20.00 秒
FAQs
We found that auto-video-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.