关于 ltx2
ltx2 是通过命令行调用 LTX-2.3 22B DiT 模型生成短视频的技能,在 Modal 上运行。它可根据提示词生成视频或为输入图像添加动画,并支持配置尺寸、帧数和推理参数。
主要功能
- 01根据提示词生成视频
- 02为输入图像添加动画
- 03配置尺寸、帧数和 FPS
- 04设置质量、步数和种子
- 05导出含环境音频的 H.264 MP4
适用场景
- 01制作短片段素材
- 02为幻灯片截图添加动态效果
- 03让静态肖像动起来
- 04制作抽象片头或片尾背景
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ calesthio/ openmontage --skill ltx2安装后在 Claude Code 中输入/ltx2确认已加载。
详细介绍
LTX-2.3 视频生成
使用 LTX-2.3 22B DiT 模型,根据文本提示词或图像生成约 5 秒的视频片段。
在 Modal(A100-80GB)上运行。需要在 .env 中设置 MODAL_LTX2_ENDPOINT_URL。
快速参考
# Text-to-video
python3 tools/ltx2.py --prompt "A sunset over the ocean, golden light on waves, cinematic" --output sunset.mp4
# Image-to-video (animate a still image)
python3 tools/ltx2.py --prompt "Gentle camera drift, soft ambient motion" --input photo.jpg --output animated.mp4
# Custom resolution and duration
python3 tools/ltx2.py --prompt "..." --width 1024 --height 576 --num-frames 161 --output wide.mp4
# Fast mode (fewer steps, quicker)
python3 tools/ltx2.py --prompt "..." --quality fast --output quick.mp4
# Reproducible output
python3 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 | 合理的默认值 | 要避免的内容 |
有效帧数
(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 秒镜头,用于旁白场景之间的转场:
python3 tools/ltx2.py --prompt "Futuristic holographic interface, glowing data visualizations, clean workspace, cinematic" --output broll_tech.mp4
python3 tools/ltx2.py --prompt "Aerial view of European city at golden hour, modern architecture" --output broll_europe.mp4
动态幻灯片背景
输入幻灯片截图,并添加轻微动态:
python3 tools/ltx2.py --prompt "Gentle particle effects, soft ambient light shifts, very slight camera drift" --input slide.png --output animated_slide.mp4
动态肖像
让静态头像栩栩如生:
python3 tools/ltx2.py --prompt "Subtle natural head movement, warm expression, professional lighting" --input headshot.png --output animated_portrait.mp4
品牌片头/片尾
为标题卡片生成抽象动态背景:
python3 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% 的生成结果可能会出现训练数据中的非预期徽标或文字。请使用不同的
--seed重新运行。 - **文字渲染:**无法在视频中可靠地生成可读文字。请改用 Remotion 叠加文字。
- **最长时长:**每个片段约 8 秒。更长的内容需要拼接。
- **音频:**生成的音频仅限环境音。语音和音乐请使用配音/音乐工具。
- **许可证:**社区许可证——收入低于 $10M 时可免费使用,超过该金额则需要商业许可证。
设置
# 1. Create Modal secret for HuggingFace (one-time)
modal secret create huggingface-token HF_TOKEN=hf_your_token
# 2. Deploy (downloads ~55GB of weights, takes ~10 min)
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
python3 tools/ltx2.py --prompt "A candle flickering on a dark table, cinematic" --output test.mp4
**重要提示:**HuggingFace 令牌需要具有读取权限的范围。部署前请接受 Gemma 3 license。未经身份验证的下载会受到严格的速率限制。
评论
支持 Markdown