关于 ltx2
ltx2 是一项命令行技能,使用 LTX-2.3 根据文本提示或静态图像生成短视频。它支持调整时长、分辨率、风格和随机种子,并通过 Modal 端点运行。
主要功能
- 01文本生成视频
- 02为静态图像添加动画
- 03设置时长和分辨率
- 04选择质量、步数和随机种子
- 05应用 crt-terminal LoRA
适用场景
- 01制作短篇转场镜头
- 02为幻灯片背景添加动态效果
- 03让肖像或插画角色动起来
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ digitalsamba/ claude-code-video-toolkit --skill ltx2安装后在 Claude Code 中输入/ltx2确认已加载。
详细介绍
LTX-2.3 视频生成
使用 LTX-2.3 22B DiT 模型,根据文本提示词或图像生成约 5 秒的视频片段。
在 Modal(A100-80GB)上运行。需要在 .env 中设置 MODAL_LTX2_ENDPOINT_URL。
LTX-2.5 可在部署时选择启用,使用同一端点;参见 LTX-2.5(选择启用)。
快速参考
# Text-to-video
uv run tools/ltx2.py --prompt "A sunset over the ocean, golden light on waves, cinematic" --output sunset.mp4
# Image-to-video (animate a still image)
uv run tools/ltx2.py --prompt "Gentle camera drift, soft ambient motion" --input photo.jpg --output animated.mp4
# Custom resolution and duration
uv run tools/ltx2.py --prompt "..." --width 1024 --height 576 --num-frames 161 --output wide.mp4
# Fast mode (fewer steps, quicker)
uv run tools/ltx2.py --prompt "..." --quality fast --output quick.mp4
# Reproducible output
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 | random | 用于确保可复现性的种子 |
--output | auto | 输出文件路径 |
--negative-prompt | sensible default | 要避免的内容 |
--lora | none | 风格 LoRA 预设。当前支持:crt-terminal。 |
风格 LoRA
风格 LoRA 会使输出偏向特定的视觉美学效果。它们已集成到 Modal 镜像中,并按请求选择;切换 LoRA 会重建服务流水线。
**在 LTX2_VERSION=2.5 部署中:**以下预设基于 LTX-2.3 训练。crt-terminal 已在 2.5 上验证(2026-10-12),但无法在该版本中复现 CRT 效果:它会改变输出,但结果是带绿色文字的照片级真实场景。请使用 2.3 部署。未匹配的权重键会被跳过且不会报错,因此在依赖任何其他 2.3 LoRA 之前,请先用 2.3 进行对比。
crt-terminal — CRT / 像素艺术终端
基础模型:LTX-2.3 22B,由 @lovis93 训练(Apache 2.0)。
# Trigger word is auto-prepended — write the prompt normally
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 帧(训练时使用的比例)
- 放宽默认负面提示词,避免屏幕文字被过滤
提示词模式:<CRT 美学> → <配色方案> → <动画风格> → <主体> → <引号中的原样文字> → <氛围>。屏幕文字保持在 1–3 个词;模型无法可靠地呈现长字符串。LoRA 更适合静态构图;如需镜头移动,请明确提出。
有效帧数
(n - 1) % 8 == 0:25(约 1 秒)、49(约 2 秒)、73(约 3 秒)、97(约 4 秒)、121(默认约 5 秒)、161(约 6.7 秒)、193(实际最长约 8 秒)。
常见分辨率
| 分辨率 | 比例 | 说明 |
|---|---|---|
| 768x512 | 3:2 | 默认,效果均衡 |
| 512x512 | 1:1 | 正方形,速度最快 |
| 1024x576 | 16:9 | 宽屏 |
| 576x1024 | 9:16 | 肖像/竖屏 |
提示词指南
LTX-2 对电影感描述的响应效果很好。可叠加以下维度:
- 镜头:“缓慢向前推进”“航拍无人机镜头”“跟踪镜头”“静态广角”
- 光线:“黄金时段”“电影感光线”“霓虹灯照明”“柔和漫射光”
- 运动:“……的延时摄影”“慢动作”“镜头轻柔漂移”“逐渐过渡”
- 风格:“使用 35mm 胶片拍摄”“纪录片风格”“简洁的极简美学”
- **负面提示词:**始终会隐式避开“最差质量、模糊、抖动、水印、文字、徽标”
提示词控制在 200 个词以内。请具体描述场景。
优质提示词
# Atmospheric b-roll
"Aerial drone shot slowly flying over turquoise ocean waves breaking on white sand, golden hour sunlight, cinematic"
# Product/tech scene
"Close-up of hands typing on a mechanical keyboard, shallow depth of field, soft desk lamp lighting, cozy atmosphere"
# Abstract background
"Dark moody abstract background with flowing blue light streaks, subtle geometric grid, bokeh particles floating, cinematic tech atmosphere"
# Animate a portrait
"Professional headshot, subtle natural head movement, confident warm expression, studio lighting, shallow depth of field"
# Animate a slide/screenshot
"Gentle subtle particle effects floating across a presentation slide, soft ambient light shifts, very slight camera drift"
不佳提示词
# Too vague
"A cool video"
# Too many competing ideas
"A cat riding a skateboard while juggling fire on the moon during a thunderstorm"
# Describing text/UI (model can't render text reliably)
"A website showing the text 'Welcome to our platform'"
视频制作应用场景
B-roll 片段
生成富有氛围感的 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 仍然更出色:
- 写实风格的人类演讲者
- 需要嘴型与音素匹配的完整句子
- 教程或访谈式讲解视频,观众实际上会通过读唇来理解内容
品牌片头/片尾
为标题卡生成抽象动态背景:
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(约 $2.50/小时)
- 推理: 每个视频片段约需 2.5 分钟(768x512、121 帧、30 步)
- 成本: 热启动时每段 5 秒视频约 $0.07;冷启动时约 $0.12,按 $2.50/小时计算(基准测试见 docs/ltx2.md)
- 权重: 约 80GB,已内置于镜像中。请求之间不会保留在 VRAM 中:每次请求(无论热启动还是冷启动)都会为每个阶段加载文本编码器和 Transformer,然后释放它们
- 输出: H.264 MP4,包含同步环境音频(24fps)
- 最长时长: 每段约 8 秒(193 帧)
已知限制
- 训练数据伪影: 约 30% 的生成结果可能会出现来自训练数据的非预期徽标或文字。使用不同的
--seed重新生成。 - 文本渲染: 无法可靠地在视频中生成可读文字。请改用 Remotion 叠加文字。
- 最长时长: 每段约 8 秒。更长的内容需要拼接。
- 音频: 生成的音频仅限环境音。语音和音乐请使用配音/音乐工具。
- 许可证: Community License——营收低于 $10M 时可免费使用,超过该金额则需要商业许可证。
设置
# 1. Create Modal secret for HuggingFace (one-time)
uv run modal secret create huggingface-token HF_TOKEN=hf_your_token
# 2. Deploy (downloads ~80GB of weights, takes ~10 min)
uv run modal deploy docker/modal-ltx2/app.py
# 3. Save endpoint URL to .env
echo "MODAL_LTX2_ENDPOINT_URL=https://yourname--video-toolkit-ltx2-ltx2-generate.modal.run" >> .env
# 4. Test
uv run tools/ltx2.py --prompt "A candle flickering on a dark table, cinematic" --output test.mp4
重要提示: HuggingFace 令牌需要具备读取权限范围。其账户需要获得 Google 的受限 Gemma 3 文本编码器访问权限;Google 会人工审批这些请求,因此请在部署前提出申请。未经身份验证的下载会受到严格的速率限制。
LTX-2.5(可选启用)
部署时设置 LTX2_VERSION=2.5,即可在相同的端点、请求格式和工具后端将 LTX-2.3 替换为 LTX-2.5。默认仍为 LTX-2.3:基准测试显示,2.5 每段视频的生成速度慢约 25-45%,且 crt-terminal LoRA 仅适用于 2.3(参见 docs/ltx2.md)。
# Git Bash / macOS / Linux. In PowerShell: $env:LTX2_VERSION='2.5' first, and
# Remove-Item Env:LTX2_VERSION before deploying 2.3 again.
LTX2_VERSION=2.5 uv run modal deploy --strategy recreate docker/modal-ltx2/app.py
# Back to 2.3 (its cached image is reused, nothing rebuilds)
uv run modal deploy --strategy recreate docker/modal-ltx2/app.py
- 访问权限:
Lightricks/LTX-2.5需要申请访问权限。请先使用令牌所属账号在模型页面点击 “Agree and Access”(自动批准;该操作会共享你的联系信息)。该模型内置 Gemma 4 文本编码器,因此 2.5 无需 Gemma 3 的访问权限。 - **许可证:**LTX-2.x Community License。年收入低于 1,000 万美元时可免费使用,包含商业用途;请勿移除水印或溯源功能。
- **检查:**每段视频生成后,工具都会打印
Model: Lightricks/LTX-2.5(或Lightricks/LTX-2.3)。 - LoRA:
crt-terminal在 2.5 上无法保持原有风格,参见上文的 Style LoRAs。 - **速度:**每段视频的生成速度比 2.3 慢约 25-45%(基准测试见
docs/ltx2.md)。
详情、差异和基准测试计划:docs/ltx2.md。