> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/shi-pin-sheng-cheng/ltx-video-2.md).

# LTX-2（音频 + 视频）

在 Clore.ai GPU 上使用 LTX-2 生成带原生音频的视频——拟音、环境声和口型同步。

LTX-2（2026年1月）是 Lightricks 的第二代视频基础模型，也是首个能够生成 **与视频同步音频的模型** 在一次前向传递中完成。它拥有 190 亿参数，能够生成带有拟音音效、环境音和口型同步语音的片段，而无需单独的音频模型。该架构继承了原始 LTX-Video 的速度优势，同时大幅扩展了能力。

在……上租用 GPU [Clore.ai](https://clore.ai/) 是运行 19B 参数模型最实用的方式——无需购买一块 2,000 美元的 GPU，只需启动一台机器即可开始生成。

## 主要特性

* **原生音频生成** ——拟音效果、环境氛围和口型同步对白与视频帧协同生成。
* **190 亿参数** ——比 LTX-Video v1 大得多的 Transformer 主干，带来更清晰的细节和更连贯的运动。
* **文本转视频 + 图像转视频** ——两种模态都支持音频输出。
* **最高 720p 分辨率** ——比 v1 模型更高保真度的输出。
* **联合音视频潜空间** ——统一的 VAE 同时编码视频和音频，保持它们在时间上的对齐。
* **开源权重** ——以宽松许可证发布，可用于商业用途。
* **Diffusers 集成** ——与 Hugging Face `diffusers` 生态系统兼容。

## 需求

| 组件        | 最低         | 推荐     |
| --------- | ---------- | ------ |
| GPU 显存    | 16 GB（带卸载） | 24+ GB |
| 系统内存      | 32 GB      | 64 GB  |
| 磁盘        | 50 GB      | 80 GB  |
| Python    | 3.10+      | 3.11   |
| CUDA      | 12.8+      | 12.8+  |
| diffusers | 0.33+      | 最新     |

**Clore.ai GPU 推荐：** 一台 **RTX 4090** （24 GB，$0.14–0.42/小时）是舒适地进行带音频的 720p 生成的最低配置。对于批量任务或更快的迭代，可筛选 **双 4090** 或 **A6000** （48 GB）在 Clore.ai 市场上的列表。

## 快速开始

```bash
# 安装依赖
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
pip install diffusers transformers accelerate sentencepiece
pip install imageio[ffmpeg] soundfile scipy

# 验证 GPU
python -c "import torch; print(torch.cuda.get_device_name(0), torch.cuda.get_device_properties(0).total_mem // 1024**3, 'GB')"
```

## 使用示例

### 带音频的文本转视频

```python
import torch
from diffusers import LTXPipeline
from diffusers.utils import export_to_video
import soundfile as sf

# 加载 LTX-2（发布时请确保使用正确的模型 ID）
pipe = LTXPipeline.from_pretrained(
    "Lightricks/LTX-Video-2",
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
pipe.enable_model_cpu_offload()

prompt = (
    "一位铁匠在砧上敲打发光的金属，火花四溅， "
    "铁锤敲击钢铁的有节奏撞击声，车间环境噪声"
)

output = pipe(
    prompt=prompt,
    negative_prompt="无声、模糊、低质量",
    num_frames=121,
    width=1280,
    height=720,
    num_inference_steps=40,
    guidance_scale=7.0,
    generator=torch.Generator("cuda").manual_seed(42),
)

# 导出视频帧
export_to_video(output.frames[0], "blacksmith.mp4", fps=24)

# 如果可用，则导出音频
if hasattr(output, "audio") and output.audio is not None:
    sf.write("blacksmith_audio.wav", output.audio, samplerate=16000)
    print("音频已单独保存——请用 ffmpeg 复用：")
    print("  ffmpeg -i blacksmith.mp4 -i blacksmith_audio.wav -c:v copy -c:a aac output.mp4")

print("完成：blacksmith.mp4")
```

### 带口型同步音频的图像转视频

```python
import torch
from PIL import Image
from diffusers import LTXImageToVideoPipeline
from diffusers.utils import export_to_video

pipe = LTXImageToVideoPipeline.from_pretrained(
    "Lightricks/LTX-Video-2",
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
pipe.enable_model_cpu_offload()

# 用于口型同步的肖像图像
image = Image.open("portrait.png").resize((720, 1280))

output = pipe(
    prompt="一个人清晰地说出 '欢迎来到 AI 视频的未来'，中性背景",
    image=image,
    num_frames=121,
    num_inference_steps=40,
    guidance_scale=7.0,
)

export_to_video(output.frames[0], "talking_head.mp4", fps=24)
```

### 带拟音的环境场景

```python
import torch
from diffusers import LTXPipeline
from diffusers.utils import export_to_video

pipe = LTXPipeline.from_pretrained(
    "Lightricks/LTX-Video-2", torch_dtype=torch.bfloat16
).to("cuda")

# 富含音频细节的提示词——明确描述声音
prompt = (
    "热带村庄里雨点落在铁皮屋顶上， "
    "远处雷声隆隆，间歇有鸟鸣， "
    "土路上的水洼泛起涟漪"
)

output = pipe(
    prompt=prompt,
    num_frames=121,
    width=1280,
    height=720,
    num_inference_steps=40,
    guidance_scale=6.5,
)

export_to_video(output.frames[0], "rain_scene.mp4", fps=24)
```

## 给 Clore.ai 用户的建议

1. **明确描述声音** ——LTX-2 的音频分支会响应提示词中的音频线索。“噼啪作响的火焰”、“踩在碎石上的脚步声”、“人群低语”比含糊的描述更能生成更好的拟音。
2. **CPU 卸载至关重要** ——在 190 亿参数规模下，模型需要 `enable_model_cpu_offload()` 在 24 GB 显卡上运行。建议预留 64 GB 系统内存。
3. **持久化存储** ——模型检查点约为 40 GB。挂载 Clore.ai 持久卷并设置 `HF_HOME` ，以避免每次容器重启都重新下载。
4. **合并音频 + 视频** ——如果管线单独输出音频，可按以下方式合并： `ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac final.mp4`.
5. **仅限 bf16** ——19B 模型采用 bf16 训练；fp16 会导致数值不稳定。
6. **在 tmux 中批量运行** ——务必在 `tmux` 在 Clore.ai 租用的实例上，以避免 SSH 断开连接时中断。
7. **检查模型 ID** ——由于 LTX-2 刚刚发布（2026 年 1 月），请在 [Lightricks 的 HF 页面](https://huggingface.co/Lightricks) 上确认准确的 Hugging Face 模型 ID 后再运行。

## 故障排查

| 问题                               | 修复                                                                                      |
| -------------------------------- | --------------------------------------------------------------------------------------- |
| `OutOfMemoryError`               | 启用 `pipe.enable_model_cpu_offload()`；确保系统内存 ≥64 GB                                      |
| 输出中没有音频                          | 音频生成可能需要显式标志或更新版 diffusers；请查看 model card 获取最新 API                                      |
| 音视频不同步                           | 使用 ffmpeg 重新封装： `ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -shortest out.mp4` |
| 生成非常慢                            | 19B 模型计算开销很大；在 RTX 4090 上每个 5 秒片段预计需要约 2–4 分钟。                                          |
| 输出 NaN                           | 使用 `torch.bfloat16` ——此模型规模不支持 fp16                                                     |
| 磁盘空间错误                           | 模型约为 40 GB；下载前请确保至少有 80 GB 可用磁盘空间                                                       |
| `ModuleNotFoundError: soundfile` | `pip install soundfile` ——用于导出 WAV 音频                                                   |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/shi-pin-sheng-cheng/ltx-video-2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
