LTX-Video简介
LTX-Video 是由 Lightricks 开发的一种开源 AI 视频生成模型,专为实时生成高质量视频而设计。它结合了先进的技术架构和高效的优化策略,能够在短时间内生成高分辨率、高帧率的视频内容。以下是关于 LTX-Video 的详细介绍:
核心特点
- 实时性能• LTX-Video 基于 DiT(Diffusion Transformer) 架构,能够在极短时间内生成高质量视频。例如,在高性能 GPU(如 NVIDIA H100)上,它可以在 4 秒内生成 5 秒的视频(分辨率为 768x512,24 FPS)。即使在中端 GPU(如 RTX 4060)上,也能在不到一分钟内生成 720x480 的视频。
- 高质量输出• 采用先进的 3D VAE(Variational Autoencoder) 技术,实现 1:192 的时空下采样,确保视频在高分辨率下依然保持高质量,同时不影响运行效率或一致性。• 新版本(如 v0.9.1)引入了改进的 VAE 解码器,消除了闪烁纹理和运动抖动伪影,进一步提升了视频质量。
- 多功能性• 支持 文本到视频(Text-to-Video) 和 图像到视频(Image-to-Video) 两种生成模式,用户可以根据需求选择使用详细的文字描述或结合图像参考来生成视频。• 提供了 内置 STG(Space-Time Guidance)和 PAG(Prompt Attention Guidance) 支持,为生成过程提供了更好的控制和灵活性。
选用该模型的很大的一个优势是成本低廉,例如海螺AI文生视频的成本在3元5秒。而使用该模型仅需0.14元,只要主要提示词描述可以生成高质量画面。
目前硅基流动的价格为
LTX-Video 调用
本地部署LTX-Video需要较好的硬件条件,可以采用调用API的方式来实现,硅基流动支持多种文生视频模型,同时部署多个大模型。
对应的官网地址硅基官网
首先进行注册然后申请api key
api调用
目前的网页版也较慢可以使用api调用
执行如下python 脚本
python video_generate.py
得到了api key值后替换如下脚本apikey的位置
import requests
url = "https://api.siliconflow.cn/v1/video/submit"
payload = {
"model": "Lightricks/LTX-Video",
"prompt": "A white sailboat gently navigating on the calm, sunlit sea. The water shimmers with reflections of the sky. In the sky above, several white seabirds are flying gracefully, their wings glistening in the sunlight. The background features a clear blue sky with a few fluffy clouds. The overall style is realistic and serene, with a high-definition photographic quality and natural, balanced colors",
}
headers = {
"Authorization": "Bearer apikey",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
执行完后会得到一串ID
Request ID: 555a5895-3b82-45f0-b60f-03ebac912d7d
再执行接收脚本
import requests
url = "https://api.siliconflow.cn/v1/video/status"
payload = {"requestId": "b51a02dd-4086-4629-9a2f-8fa6d32f4961"}
headers = {
"Authorization": "Bearer api key",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
if response.status_code == 200:
# 打开一个文件用于保存视频
with open("downloaded_video.mp4", "wb") as file:
# 按块写入文件,避免占用过多内存
for chunk in response.iter_content(chunk_size=8192):
file.write(chunk)
print("视频下载成功,已保存为 downloaded_video.mp4")
else:
print(f"视频下载失败,状态码:{response.status_code}")
之后就可以得到视频的下载·地址
{“status”:“Succeed”,“position”:0,“reason”:“”,“results”:{“videos”:[{“url”:“https://sc-maas.oss-cn-shanghai.aliyuncs.com/outputs/b51a02dd-4086-4629-9a2f-8fa6d32f4961_00001.mp4?OSSAccessKeyId=LTAI5tQnPSzwAnR8NmMzoQq4\u0026Expires=1739367163\u0026Signature=d%2Fw6ObAkyLI7fUDfeKNjDui7TT4%3D”}],“timings”:{“inference”:1.255},“seed”:1},
这里写了一个直接下载视频到本地的脚本
视频生成下载脚本