一、项目环境清单(真实踩坑记录)
- 硬件:RTX4090 24G;最低兼容 RTX3090/4070Ti 12G(12G 显存必须开启 FP8 量化,关闭 VAE 分块容易爆显存)
- 模型:Wan2.2 14B T2V FP8、Wan2.2 Fun-InP 首尾帧过渡模型、IP-Adapter face 角色参考、Realistic Vision V5(生成分镜静帧)
- 自定义节点:ComfyUI-VideoHelperSuite、ComfyUI-IPAdapter、FFmpeg(系统环境变量注册)
- 输出规格:竖屏 9:16,分辨率 720×1280,16fps,单镜头 4s,总片长 35s 左右
坑点记录:Wan2.2 原生对大幅度肢体动作容易崩坏,感人向短片优先控制动作幅度为「微动、缓慢转头、眼神变化」,不要写大幅度奔跑、跳跃镜头;反向提示词必须固定,否则前后镜头画风漂移严重ComfyUI
二、故事设定、分镜表与全套提示词库
故事梗概
小小的圆滚滚外星人迫降在郊外林间小屋外,好奇地隔着玻璃窗看独居老爷爷喂麻雀;老爷爷无意间发现它,没有害怕,放了一块小饼干在窗台。外星人不敢靠近,深夜悄悄留下一颗会微弱发光的种子,登上破损飞碟离开。第二天老爷爷醒来,窗台长出一朵蓝色微光小花。
分镜表(共 8 镜)
表格
| 镜号 | 时长 | 运镜 | 画面简述 | 正向提示词 | 反向提示词 |
| 1 | 4s | 缓慢推镜 | 黄昏森林,飞碟冒着淡蓝轻烟落在草地,舱门打开,圆滚滚小外星人探出脑袋,大眼睛,软乎乎半透明皮肤,治愈暖光 | cute round alien, big watery black eyes, translucent pale blue skin, tiny tentacles on head, small broken UFO, dusk forest, golden hour rim light, cinematic soft focus, 9:16, slow subtle movement, no fast motion, emotional warm atmosphere | deformed limbs, extra eyes, ugly, blurry, distorted face, text, watermark, fast shake, noisy, overexposed |
| 2 | 4s | 固定机位 | 外星人踮脚,躲在灌木后,远远望向林间木屋窗户 | small alien peeking behind bush, looking at wooden cottage window, soft shadow, bokeh background, gentle wind sway leaves, slight body breathing motion | deformed, mutated, disfigured, sharp teeth, horror, harsh flash |
| 3 | 5s | 横移慢镜 | 屋内老爷爷,白发,坐在窗边,把面包屑撒在窗台喂麻雀,暖黄台灯 | elderly grandpa, white hair, worn knit sweater, feeding sparrow on windowsill, warm indoor lamp light, cozy room depth of field, slow hand movement | cartoon exaggeration, ugly face, broken hand, extra fingers |
| 4 | 5s | 特写 | 老爷爷抬头,视线无意间对上窗外外星人,愣住,眼神温和不恐惧 | close-up shot, grandpa eyes wide, surprise but calm, eye micro movement, warm lighting, shallow depth of field | cross-eye, distorted iris, weird teeth |
| 5 | 4s | 慢推 | 老爷爷拿起一块饼干,轻轻放在窗台边缘,后退半步 | grandpa put cookie on windowsill, slow gentle action, soft indoor light, shadow cast on window glass | fast movement, trembling wildly, broken objects |
| 6 | 4s | 特写 | 外星人犹豫很久,不敢上前,指尖轻轻悬在半空,大眼睛闪烁微光 | close-up alien big eyes, hesitate, fingertips slightly trembling, faint bioluminescence on skin, cool ambient twilight, subtle glow | over-bright, glare, messy pixel, limb twist |
| 7 | 5s | 拉远镜头 | 深夜,外星人把一颗发光种子放在窗台,转身跳回飞碟,飞碟缓缓升空,淡蓝色尾焰 | night scene, alien leave glowing seed on windowsill, turn back to UFO, UFO lift off slowly, soft blue trail, starry sky, quiet atmosphere | explosion, bright flash, chaotic, sharp motion blur |
| 8 | 4s | 固定清晨镜头 | 第二天清晨,窗台饼干还在,种子长出一朵淡蓝色发光小花,阳光落在花瓣上 | morning sun, blue glowing small flower on windowsill, cookie beside flower, soft morning haze, peaceful, warm tone | dark, gloomy, wilted flower, ugly texture |
角色统一核心提示词(每镜都要放在 prompt 最前面):
masterpiece, best quality, consistent character, same alien, round body, two big round eyes, translucent pale blue skin, tiny head tentacles, character reference IP-Adapter
三、ComfyUI 工作流配置要点
- 首镜先生成外星人参考图,送入 IP-Adapter 节点,后续全部镜头都挂载这张参考图,锁定外形,解决变脸;
- 镜头 1、7 使用 Wan2.2 T2V;镜头 2-6、8 优先使用 I2V 图生视频,先生成分镜静帧,再送入视频模型,稳定性远高于纯文生视频;
- 采样器推荐:
flow_euler,步数 28,CFG scale=6; - 保存工作流 json:
alien_shortfilm_workflow.json,放在项目根目录,脚本可以自动加载队列提交任务。
四、Python 批量渲染脚本(调用 ComfyUI API 提交任务)
依赖:
requests,ComfyUI 开启 API(默认地址 http://127.0.0.1:8188);脚本自动读取分镜列表,逐个提交生成任务,输出视频保存到./output_clips/
import requests import json import os import time COMFYUI_URL = "http://127.0.0.1:8188" WORKFLOW_PATH = "./alien_shortfilm_workflow.json" OUTPUT_DIR = "./output_clips" os.makedirs(OUTPUT_DIR, exist_ok=True) shot_list = [ { "shot_id": 1, "prompt": "cute round alien, big watery black eyes, translucent pale blue skin, tiny tentacles on head, small broken UFO, dusk forest, golden hour rim light, cinematic soft focus, 9:16, slow subtle movement, no fast motion, emotional warm atmosphere, masterpiece, best quality, consistent character, same alien, round body, two big round eyes, translucent pale blue skin, tiny head tentacles", "neg_prompt": "deformed limbs, extra eyes, ugly, blurry, distorted face, text, watermark, fast shake, noisy, overexposed", "duration": 4 }, { "shot_id": 2, "prompt": "small alien peeking behind bush, looking at wooden cottage window, soft shadow, bokeh background, gentle wind sway leaves, slight body breathing motion, masterpiece, best quality, consistent character, same alien", "neg_prompt": "deformed, mutated, disfigured, sharp teeth, horror, harsh flash", "duration": 4 }, { "shot_id": 3, "prompt": "elderly grandpa, white hair, worn knit sweater, feeding sparrow on windowsill, warm indoor lamp light, cozy room depth of field, slow hand movement, masterpiece, best quality", "neg_prompt": "cartoon exaggeration, ugly face, broken hand, extra fingers", "duration": 5 }, { "shot_id": 4, "prompt": "close-up shot, grandpa eyes wide, surprise but calm, eye micro movement, warm lighting, shallow depth of field, masterpiece, best quality", "neg_prompt": "cross-eye, distorted iris, weird teeth", "duration": 5 }, { "shot_id": 5, "prompt": "grandpa put cookie on windowsill, slow gentle action, soft indoor light, shadow cast on window glass, masterpiece, best quality", "neg_prompt": "fast movement, trembling wildly, broken objects", "duration": 4 }, { "shot_id": 6, "prompt": "close-up alien big eyes, hesitate, fingertips slightly trembling, faint bioluminescence on skin, cool ambient twilight, subtle glow, masterpiece, best quality, consistent character, same alien", "neg_prompt": "over-bright, glare, messy pixel, limb twist", "duration": 4 }, { "shot_id": 7, "prompt": "night scene, alien leave glowing seed on windowsill, turn back to UFO, UFO lift off slowly, soft blue trail, starry sky, quiet atmosphere, masterpiece, best quality, consistent character, same alien", "neg_prompt": "explosion, bright flash, chaotic, sharp motion blur", "duration": 5 }, { "shot_id": 8, "prompt": "morning sun, blue glowing small flower on windowsill, cookie beside flower, soft morning haze, peaceful, warm tone, masterpiece, best quality", "neg_prompt": "dark, gloomy, wilted flower, ugly texture", "duration": 4 } ] def load_workflow(): with open(WORKFLOW_PATH, "r", encoding="utf-8") as f: return json.load(f) def queue_prompt(prompt): payload = {"prompt": prompt} r = requests.post(f"{COMFYUI_URL}/prompt", json=payload) return r.json() def wait_for_execution(prompt_id): while True: res = requests.get(f"{COMFYUI_URL}/history/{prompt_id}") history = res.json() if prompt_id in history: return history[prompt_id] time.sleep(3) if __name__ == "__main__": base_workflow = load_workflow() for shot in shot_list: print(f"开始提交镜号 {shot['shot_id']}") workflow = json.loads(json.dumps(base_workflow)) # 替换工作流里正向、反向提示词节点,根据你自己节点ID修改 workflow["6"]["inputs"]["text"] = shot["prompt"] workflow["7"]["inputs"]["text"] = shot["neg_prompt"] res = queue_prompt(workflow) prompt_id = res["prompt_id"] print(f"任务ID:{prompt_id},等待渲染完成") history_data = wait_for_execution(prompt_id) print(f"镜号{shot['shot_id']}渲染完成\n") time.sleep(2) print("✅ 全部镜头提交完成,去ComfyUI输出目录取出视频片段")
使用说明:打开 ComfyUI,先加载一次工作流,确认正向提示词节点 ID 是
6、反向是7,和代码对应;如果你的节点编号不一样,自行修改workflow["6"]这里。
五、FFmpeg 后期自动合成脚本(拼接、加字幕、调色、导出成片)
用途:把零散镜头按顺序拼接、统一 LUT 调色、叠加旁白字幕、压缩码率适配短视频平台;生成成片
alien_final_35s.mp4
import subprocess import os # 镜头顺序,对应output_clips内生成出来的片段文件名 clip_order = [ "shot_0001.mp4", "shot_0002.mp4", "shot_0003.mp4", "shot_0004.mp4", "shot_0005.mp4", "shot_0006.mp4", "shot_0007.mp4", "shot_0008.mp4" ] clip_dir = "./output_clips" concat_list_file = "./concat_list.txt" final_out = "./alien_final_35s.mp4" # 字幕文本,时间轴和分镜对齐 subtitle_text = """ 1:00:00,0 --> 00:00:04,0 迷路的小外星人,降落在森林边 2:00:04,0 --> 00:00:08,0 好奇地,悄悄望向小屋 3:00:08,0 --> 00:00:13,0 老爷爷正在窗边喂麻雀 4:00:13,0 --> 00:00:18,0 他看见了窗外的小访客 5:00:18,0 --> 00:00:22,0 递出一块饼干 6:00:22,0 --> 00:00:26,0 外星人有点害怕,不敢靠近 7:00:26,0 --> 00:00:31,0 深夜,它留下一颗发光种子离开 8:00:31,0 --> 00:00:35,0 第二天,窗台开出微光小花 """ # 生成concat列表 with open(concat_list_file, "w", encoding="utf-8") as f: for name in clip_order: f.write(f"file '{os.path.join(clip_dir, name)}'\n") sub_file = "./subtitle.srt" with open(sub_file, "w", encoding="utf-8") as f: f.write(subtitle_text) # FFmpeg拼接 + 调色 + 字幕 cmd = [ "ffmpeg", "-y", "-f", "concat", "-safe", "0", "-i", concat_list_file, "-vf", "eq=gamma=0.95:contrast=1.05:saturation=1.1,subtitles=" + sub_file, "-c:v", "libx264", "-crf", "23", "-preset", "medium", "-c:a", "aac", "-b:a", "128k", final_out ] print("执行FFmpeg合成:", " ".join(cmd)) subprocess.run(cmd, check=True) print(f"\n🎉 成片输出完成:{final_out}")
六、后期优化与上线调优经验(真实落地经验)
- 音频方案:不要用 AI 自动生成嘈杂人声,这个短片适合低音量治愈纯音乐 + 轻微环境音(风声、鸟鸣、飞碟低频嗡鸣),在剪映里叠加上去;
- 角色一致性兜底方案:如果某一镜外星人变脸严重,放弃 T2V,先生成一张静态参考图,IP-Adapter 权重拉高到 0.75,走 I2V;IP 权重太高画面会僵硬,推荐区间 0.55~0.7;
- 短视频分发:成片导出后,加轻微胶片颗粒,降低 AI 感;标题走温情路线:《它没有带走饼干,留下一朵星星花》;
- 资源包说明:夸克网盘内附带完整工作流 json、打包好的提示词文档、srt 字幕模板、调色预设,直接下载替换即可跑,不用手动复制分镜。
七、常见报错排查
- ComfyUI API 连接失败:确认 ComfyUI 已经启动,不要开代理占用 8188 端口;
- FFmpeg 报错找不到文件:所有视频片段文件名不要带中文、空格;
- 视频闪烁:Wan2.2 生成后如果画面频闪,可以在 vf 滤镜增加
deshake或者降低采样 CFG; - 显存溢出:在工作流开启模型 FP8 量化,VAE tiling 开启,单镜头不要超过 5s。
配套资源直达
完整资源模型:https://pan.quark.cn/s/54abd91fbd4a包里包含:alien_shortfilm_workflow.json、分镜提示词文档、字幕模板、调色 LUT 参考、样片对比图。