Put four styles in one ASS file at the same time:Sub(bottom subtitles) · Hook(pop-up large text effects) · Tag(top-left sticker) · CTA(call-to-action button). Script:scripts/make_subs.py。
Part of ecommerce-video-skills
Inputs Inputs
- Timeline JSON (
ffmpeg-auto-assembleautomatically generatedbuild/timing.json), or write your own:
{"size": [1080, 1920], "cues": [
{"start": 0.10, "end": 2.70, "text": "冰水撑不到中午?", "style": "Hook"},
{"start": 0.15, "end": 2.60, "text": "冰水不到中午就**变温**了?", "style": "Sub"},
{"start": 0.00, "end": 17.0, "text": "AURA 保温杯", "style": "Tag"},
{"start": 14.2, "end": 17.0, "text": "点击下方链接 ›", "style": "CTA"}]}
Markup Markup
| Syntax | Effect |
|---|---|
**关键词** |
Change the keyword to the highlight color (default warm yellow) |
| `Fill with ice cubes in the morning | and the ice cubes are still there by evening` |
Steps Steps
- Each subtitle ≤ 14 Chinese characters (1080 wide ≈ one line); if longer, use
|to split. - Highlight only 1 keyword per subtitle; text effects ≤ 10 characters, used only for the hook and key selling points.
- Generate:
python scripts/make_subs.py build/timing.json -o build/subs.ass --srt build/subs.srt - Burn in:
ffmpeg -i in.mp4 -vf "ass=build/subs.ass" -c:a copy out.mp4 - If the platform supports uploading subtitle files (such as YouTube / some ad platforms), also deliver
.srt。
Safe zones Safe zones (rule-of-thumb values, subject to actual device testing)
- Bottom about 20%: title copy, product card, shopping cart → subtitles
MarginVdefault 26% height - Right side about 15%: like/comment/share buttons → left and right margins 70px, do not place important information near the right side
- Top about 8%: status bar/search → place the Hook at 13% height
- Use
python skills/platform-spec-export/scripts/export_platform.py video.mp4 --safe-preview safe.png(run in the repository root directory) overlay check
Style customization
Edit make_subs.py in header(): font size is calculated as a proportion of the frame height (applicable to 9:16 / 1:1 / 16:9), colors are ASS &HAABBGGRR. Fonts are automatically detected (Noto Sans CJK SC / Source Han Sans / PingFang / Microsoft YaHei), and you can also --font "思源黑体 CN"。
Prompt template Prompt template
把这段口播稿拆成短视频字幕:每条 ≤14 字,超过用 | 分段;每条最多 1 个关键词用 **加粗**;
另外为钩子镜头和最强卖点各写 1 条 ≤10 字的花字。输出 JSON cues(start/end 先留空)。口播稿:{…}
Checklist Checklist
- Subtitles do not cover the product subject and do not enter the bottom 20% / right-side button area
- At most 2 lines per screen; keyword highlights ≤ 1
- Check typos/brand spelling; numbers match the voiceover
- Chinese fonts are installed (otherwise boxes will appear)
Common issues and fixes Failure fixes
| Issue | Fix |
|---|---|
| Chinese displays as boxes | Install a CJK font (apt install fonts-noto-cjk) or --font specify an installed font |
No such filter: 'ass' |
ffmpeg was not compiled with libass; switch to the official/distribution full version of ffmpeg |
| Path contains a colon and reports an error (Windows) | Use a relative path or write C: as C\:; the script already escapes automatically |
| Subtitles and audio are out of sync | Generate timing using the actual voiceover duration (assemble.py already handles this automatically) |
| Subtitles are too small | Adjust header() in sub = round(h * 0.037) the coefficient of |