使用 LTX-2.3 22B 模型进行 AI 视频生成 —— 支持文本生成视频(Text-to-Video)以及用于视频制作的图生视频(Image-to-Video)片段。适用于生成视频剪辑、让静态图像动起来、制作空镜头(B-roll)、动态背景或运动内容。触发词包括视频生成、图像动画化、b-roll、动态、视频片段、文生视频、图生视频。
LTX-2.3 视频生成
使用 LTX-2.3 22B DiT 模型从文本提示词或图像生成约 5 秒的视频片段。
运行在 Modal (A100-80GB) 上。需要在 .env 中配置 MODAL_LTX2_ENDPOINT_URL。
快速参考
# 文生视频
uv run tools/ltx2.py --prompt "A sunset over the ocean, golden light on waves, cinematic" --output sunset.mp4
# 图生视频(让静态图片动起来)
uv run tools/ltx2.py --prompt "Gentle camera drift, soft ambient motion" --input photo.jpg --output animated.mp4
# 自定义分辨率和时长
uv run tools/ltx2.py --prompt "..." --width 1024 --height 576 --num-frames 161 --output wide.mp4
# 快速模式(步数更少,生成更快)
uv run tools/ltx2.py --prompt "..." --quality fast --output quick.mp4
# 可复现的输出
uv run tools/ltx2.py --prompt "..." --seed 42 --output reproducible.mp4
参数说明
| 参数 | 默认值 | 描述 |
|---|---|---|
--prompt |
(必填) | 视频的文本描述 |
--input |
- | 用于图生视频的输入图像 |
--width |
768 | 视频宽度(必须能被 64 整除) |
--height |
512 | 视频高度(必须能被 64 整除) |
--num-frames |
121 | 帧数,必须满足 (n-1) % 8 == 0 |
--fps |
24 | 每秒帧数 |
--quality |
standard | standard (30 步) 或 fast (15 步) |
--steps |
30 | 直接覆盖推理步数 |
--seed |
随机 | 用于复现结果的随机种子 |
--output |
自动 | 输出文件路径 |
--negative-prompt |
合理默认值 | 需要避免出现的内容 |
--lora |
无 | 风格 LoRA 预设。目前仅支持:crt-terminal。 |
风格 LoRA
风格 LoRA 会引导输出偏向特定的视觉美学。它们预置在 Modal 镜像中,按请求加载;切换 LoRA 会强制重新构建管道(在容器生命周期内,每次切换有一次性约 60 秒的开销)。
crt-terminal — CRT / 像素风终端
基座模型:LTX-2.3 22B,由 @lovis93 训练 (Apache 2.0)。
# 触发词会自动前置追加 —— 按正常方式编写提示词即可
uv run tools/ltx2.py --lora crt-terminal \
--prompt "a terminal typing out \"\\$ claude --continue\" character by character in glowing green pixel font, scanlines, phosphor glow, low choppy frame rate, hacker mood" \
--output crt_claude.mp4
预设带来的改动:
- 在提示词前自动追加
crtanim,(LoRA 的触发词) - 默认分辨率设为 1024×1024,121 帧(该 LoRA 训练时使用的比例)
- 放宽默认负向提示词,防止屏幕上的文字被过滤掉
提示词结构模式: <CRT aesthetic> → <color palette> → <animation style> → <subject> → <literal text in quotes> → <mood>。建议将屏幕文字控制在 1-3 个单词以内 —— 该模型无法稳定渲染长文本。该 LoRA 倾向于静态构图;如果需要镜头移动,请明确在提示词中写出。
有效帧数
(n - 1) % 8 == 0:25 (~1s)、49 (~2s)、73 (~3s)、97 (~4s)、121 (~5s 默认)、161 (~6.7s)、193 (~8s 实际最大值)。
常用分辨率
| 分辨率 | 宽高比 | 备注 |
|---|---|---|
| 768x512 | 3:2 | 默认,各方面平衡良好 |
| 512x512 | 1:1 | 正方形,速度最快 |
| 1024x576 | 16:9 | 宽屏 |
| 576x1024 | 9:16 | 竖屏 |
提示词编写指南
LTX-2 对电影镜头式的描述响应极佳。可以叠加以下维度:
- 镜头(Camera): "Slow dolly forward"(缓慢推镜头)、"Aerial drone shot"(无人机航拍)、"Tracking shot"(跟踪镜头)、"Static wide angle"(固定广角)
- 光照(Lighting): "Golden hour"(黄金光线)、"Cinematic lighting"(电影级光照)、"Neon-lit"(霓虹灯光)、"Soft diffused light"(柔和漫射光)
- 动态(Motion): "Timelapse of..."(……的延时摄影)、"Slow motion"(慢动作)、"Gentle camera drift"(轻微镜头漂移)、"Gradually transitions"(渐变过渡)
- 风格(Style): "Shot on 35mm film"(35mm 胶片拍摄)、"Documentary style"(纪录片风格)、"Clean minimal aesthetic"(干净极简美学)
- 负向(Negative): 始终隐式避免出现 "worst quality, blurry, jittery, watermark, text, logo"
请将提示词控制在 200 字以内,并对场景细节保持精准具体。
优秀提示词示例
# 氛围空镜头(b-roll)
"Aerial drone shot slowly flying over turquoise ocean waves breaking on white sand, golden hour sunlight, cinematic"
# 产品/科技场景
"Close-up of hands typing on a mechanical keyboard, shallow depth of field, soft desk lamp lighting, cozy atmosphere"
# 抽象背景
"Dark moody abstract background with flowing blue light streaks, subtle geometric grid, bokeh particles floating, cinematic tech atmosphere"
# 静态肖像动画化
"Professional headshot, subtle natural head movement, confident warm expression, studio lighting, shallow depth of field"
# 演示幻灯片/截图动画化
"Gentle subtle particle effects floating across a presentation slide, soft ambient light shifts, very slight camera drift"
不佳提示词示例
# 过于含糊
"A cool video"
# 包含过多相互冲突的想法
"A cat riding a skateboard while juggling fire on the moon during a thunderstorm"
# 描述文本/UI(模型无法稳定渲染文字)
"A website showing the text 'Welcome to our platform'"
视频制作应用场景
空镜头剪辑(B-Roll Clips)
生成 5 秒的氛围镜头,用于旁白场景之间的过场切换:
uv run tools/ltx2.py --prompt "Futuristic holographic interface, glowing data visualizations, clean workspace, cinematic" --output broll_tech.mp4
uv run tools/ltx2.py --prompt "Aerial view of European city at golden hour, modern architecture" --output broll_europe.mp4
动画化幻灯片背景
输入幻灯片截图并添加微妙的动态效果:
uv run tools/ltx2.py --prompt "Gentle particle effects, soft ambient light shifts, very slight camera drift" --input slide.png --output animated_slide.mp4
肖像动画化
让静态头像变得生动:
uv run tools/ltx2.py --prompt "Subtle natural head movement, warm expression, professional lighting" --input headshot.png --output animated_portrait.mp4
风格化角色客串(SadTalker 替代方案)
对于非真人面孔 —— 如奇幻角色、带面具人物、浓密胡须、头盔、插画等 —— SadTalker 常常会产生诡异或破绽百出的口型同步,因为它主要是针对真人进行训练的。当口型精准度不是关键时,LTX-2 图生视频往往是更好的选择(只要有动态内容,观众的大脑就会自动填补口型缝隙)。编写提示词时请专注于动态 + 氛围,而非发音口型:
uv run tools/ltx2.py \
--input character_portrait.png \
--prompt "Ancient warrior speaks slowly with gravitas, beard shifts subtly, glowing aura pulses, embers drift past, slow head movement, cinematic close-up, mystical atmosphere" \
--width 768 --height 768 \
--output character_speaking.mp4
LTX-2 优于 SadTalker 的场景:
- 风格化 / 插画 / 奇幻角色
- 浓密的面部毛发或遮挡嘴部的饰品
- 戴面具或头盔的人物
- 氛围重于口型精准度的短暂客串台词
- 戏剧性旁白而非纯对话
SadTalker 仍具优势的场景:
- 逼真的真人出镜主持人
- 嘴型需要与音素精准匹配的完整句子
- 观众实际上会在阅读唇语的教程 / 数字人讲解视频
品牌 Intro/Outro(片头/片尾)
为标题卡生成抽象动态背景:
uv run tools/ltx2.py --prompt "Dark moody background with flowing blue and coral light streaks, bokeh particles, cinematic tech atmosphere, no text" --output intro_bg.mp4
与其他工具结合使用
LTX-2 用于生成原始片段。可与工具包中的其他工具结合:
| 工作流 | 工具组合 |
|---|---|
| 生成片段 → 超分辨率放大 | ltx2.py → upscale.py |
| 生成片段 → 添加到 Remotion | ltx2.py → 在合成中用作 <OffthreadVideo> |
| 生成图像 → 动画化 | flux2.py → ltx2.py --input |
| 生成片段 → 提取音频 | ltx2.py → ffmpeg -i clip.mp4 -vn audio.wav |
| 生成片段 → 添加配音旁白 | ltx2.py → 与 qwen3_tts.py 输出混合 |
技术细节
- 模型: LTX-2.3 22B DiT (Lightricks),bf16
- GPU: Modal 上的 A100-80GB (约 $4.68/小时)
- 推理耗时: 每个片段约 2.5 分钟 (768x512, 121 帧, 30 步)
- 成本: 每个 5 秒片段约 $0.20-0.25
- 冷启动: 约 60-90 秒 (加载约 55GB 权重)
- 输出: 带有同步环境音效的 H.264 MP4 (24fps)
- 最大时长: 每个片段约 8 秒 (193 帧)
已知局限
- 训练数据瑕疵: 约 30% 的生成结果可能会带有来自训练数据的残留 Logo 或文本。遇到时请更改
--seed重新运行。 - 文本渲染: 无法稳定生成视频中可读的文本。请改用 Remotion 叠加文字。
- 最大时长: 每个片段约 8 秒。更长的内容需要后续拼接。
- 音频: 生成的音频仅为环境音/背景音。语音与音乐请使用专门的配音/音乐工具。
- 许可证: 社区许可证(Community License)—— 营收低于 $10M 可免费使用,高于该数额需要商业授权。
环境配置
# 1. 为 HuggingFace 创建 Modal secret(一次性设置)
uv run modal secret create huggingface-token HF_TOKEN=hf_your_token
# 2. 部署(下载约 55GB 权重,耗时约 10 分钟)
uv run modal deploy docker/modal-ltx2/app.py
# 3. 将 Endpoint URL 保存至 .env
echo "MODAL_LTX2_ENDPOINT_URL=https://yourname--video-toolkit-ltx2-ltx2-generate.modal.run" >> .env
# 4. 测试运行
uv run tools/ltx2.py --prompt "A candle flickering on a dark table, cinematic" --output test.mp4
重要提示: HuggingFace token 需要具备读取权限范围。部署前请先接受 Gemma 3 许可证协议。未认证的下载将会受到严格的速率限制。






