-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo_generation.py
More file actions
100 lines (82 loc) · 2.35 KB
/
video_generation.py
File metadata and controls
100 lines (82 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""Video generation examples.
Demonstrates text-to-video, image-to-video, upscale, and background removal.
Usage:
export DEAPI_API_KEY="sk-your-api-key"
python examples/video_generation.py
"""
from deapi import DeapiClient
client = DeapiClient()
# --- Text-to-video ---
print("Generating video from text...")
job = client.video.generate(
prompt="a rocket launching into space, cinematic, slow motion",
negative_prompt="blurry, low quality",
model="Ltx2_19B_Dist_FP8",
width=768,
height=512,
steps=1,
seed=42,
frames=120,
fps=24,
)
print(f"Job submitted: {job.request_id}")
result = job.wait()
print(f"Status: {result.status}")
print(f"Video URL: {result.result_url}")
# --- Image-to-video (animate a still image) ---
# Uncomment to run — requires an image file:
#
# print("\nAnimating image...")
# job = client.video.animate(
# prompt="gentle camera pan across the landscape with clouds moving",
# first_frame_image="landscape.jpg",
# model="Ltx2_19B_Dist_FP8",
# seed=42,
# width=768,
# height=512,
# frames=120,
# fps=24,
# )
# result = job.wait()
# print(f"Animated video: {result.result_url}")
# --- With first and last frame (for controlled transitions) ---
# Uncomment to run — requires two image files:
#
# job = client.video.animate(
# prompt="smooth transition from day to night",
# first_frame_image="daytime.jpg",
# last_frame_image="nighttime.jpg",
# model="Ltx2_19B_Dist_FP8",
# seed=42,
# width=768,
# height=512,
# frames=120,
# fps=24,
# )
# --- Video upscale ---
# Uncomment to run — requires a video file:
#
# print("\nUpscaling video...")
# job = client.video.upscale(video="low_res.mp4", model="vid-upscale-model")
# result = job.wait()
# print(f"Upscaled: {result.result_url}")
# --- Video background removal ---
# Uncomment to run — requires a video file:
#
# print("\nRemoving video background...")
# job = client.video.remove_background(video="greenscreen.mp4", model="vid-rmbg-model")
# result = job.wait()
# print(f"Background removed: {result.result_url}")
# --- Price calculation ---
price = client.video.generate_price(
prompt="a rocket launching",
model="Ltx2_19B_Dist_FP8",
width=768,
height=512,
steps=1,
seed=42,
frames=120,
fps=24,
)
print(f"\nVideo generation price: ${price.price}")
client.close()