-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic_video_examples.py
More file actions
executable file
Β·236 lines (203 loc) Β· 8.38 KB
/
dynamic_video_examples.py
File metadata and controls
executable file
Β·236 lines (203 loc) Β· 8.38 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/usr/bin/env python3
"""
Dynamic Video Generation Examples - Enhanced Motion
This script demonstrates the enhanced video generation with improved motion and dynamics.
The system now automatically creates more cinematic, fluid videos with natural movement
and eliminates static text/letters from appearing in videos.
Key Improvements:
- Smart motion enhancement based on scene type
- Cinematic camera movement
- Natural element animation (water, leaves, clouds, etc.)
- No text/letters in videos
- Enhanced image generation for better animation potential
"""
from src.text_extractor import TextExtractor
import json
import time
def test_dynamic_scenes():
"""Test various scene types with enhanced dynamic motion."""
extractor = TextExtractor()
test_scenarios = [
{
"name": "Ocean Waves Scene",
"image_prompt": "A dramatic ocean coastline with powerful waves crashing against rocky cliffs",
"expected_motion": "Dynamic water movement, crashing waves, mist, atmospheric effects",
"voice": "onyx",
"style": "descriptive"
},
{
"name": "Forest Wind Scene",
"image_prompt": "A mystical forest with tall ancient trees and rays of sunlight",
"expected_motion": "Swaying leaves, shifting light, atmospheric depth, natural movement",
"voice": "shimmer",
"style": "meditative"
},
{
"name": "Mountain Storm Scene",
"image_prompt": "A majestic mountain landscape with dramatic storm clouds gathering",
"expected_motion": "Moving clouds, atmospheric changes, dynamic lighting, weather effects",
"voice": "echo",
"style": "educational"
},
{
"name": "Garden Paradise Scene",
"image_prompt": "A beautiful flower garden with butterflies and gentle breeze",
"expected_motion": "Petals falling, butterflies flying, plants swaying, organic movement",
"voice": "nova",
"style": "poetic"
},
{
"name": "Fire & Light Scene",
"image_prompt": "A cozy campfire under a starry night sky",
"expected_motion": "Flickering flames, dancing light, twinkling stars, atmospheric glow",
"voice": "fable",
"style": "meditative"
}
]
print("π¬ DYNAMIC VIDEO GENERATION SHOWCASE")
print("Enhanced Motion & Cinematic Movement")
print("=" * 60)
print()
results = []
for i, scenario in enumerate(test_scenarios, 1):
print(f"π₯ Test {i}: {scenario['name']}")
print(f"π Scene: {scenario['image_prompt']}")
print(f"π― Expected Motion: {scenario['expected_motion']}")
print(f"ποΈ Voice: {scenario['voice']} ({scenario['style']} style)")
print()
start_time = time.time()
try:
result = extractor.generate_video_from_prompt(
image_prompt=scenario['image_prompt'],
video_prompt=None, # Let system auto-generate dynamic motion
duration=10, # Longer duration to see motion
voice_type=scenario['voice'],
style=scenario['style']
)
result_data = json.loads(result)
processing_time = time.time() - start_time
if result_data.get('status') == 'success':
print("β
SUCCESS!")
print(f"π¬ Video URL: {result_data.get('video_url')}")
if result_data.get('has_audio'):
print(f"ποΈ Audio URL: {result_data.get('audio_url')}")
print(f"β±οΈ Processing Time: {processing_time:.1f}s")
# Save result
scenario_result = {
"scenario": scenario['name'],
"video_url": result_data.get('video_url'),
"audio_url": result_data.get('audio_url'),
"processing_time": processing_time,
"status": "success"
}
results.append(scenario_result)
else:
print(f"β Failed: {result_data.get('error')}")
results.append({
"scenario": scenario['name'],
"status": "failed",
"error": result_data.get('error')
})
except Exception as e:
print(f"β Exception: {e}")
results.append({
"scenario": scenario['name'],
"status": "exception",
"error": str(e)
})
print()
# Brief pause between tests
if i < len(test_scenarios):
print("βΈοΈ Waiting 15 seconds before next test...")
time.sleep(15)
print()
# Summary
print("π DYNAMIC VIDEO GENERATION SUMMARY")
print("=" * 40)
successful = sum(1 for r in results if r['status'] == 'success')
total = len(results)
print(f"β
Successful: {successful}/{total}")
print(f"β±οΈ Average processing time: {sum(r.get('processing_time', 0) for r in results if 'processing_time' in r) / max(successful, 1):.1f}s")
print()
print("π― EXPECTED IMPROVEMENTS IN VIDEOS:")
print("β’ More fluid and natural motion")
print("β’ Enhanced cinematic camera movement")
print("β’ NO text or letters appearing in videos")
print("β’ Scene-appropriate dynamic elements:")
print(" - Water: flowing, rippling, crashing")
print(" - Trees: swaying, rustling leaves")
print(" - Clouds: drifting, forming, changing")
print(" - Fire: flickering, dancing flames")
print(" - Flowers: petals falling, plants moving")
print()
print("π‘ TECHNICAL ENHANCEMENTS:")
print("β’ Smart prompt enhancement based on scene type")
print("β’ Automatic motion keywords injection")
print("β’ Quality enhancers for cinematic results")
print("β’ Text/letter elimination from videos")
print("β’ Animation-optimized image generation")
# Save results
timestamp = time.strftime("%Y%m%d_%H%M%S")
filename = f"dynamic_video_results_{timestamp}.json"
with open(filename, 'w') as f:
json.dump(results, f, indent=2)
print()
print(f"πΎ Results saved to: {filename}")
def show_curl_examples():
"""Show CURL examples for testing dynamic video generation."""
print("\nπ CURL EXAMPLES FOR DYNAMIC VIDEO GENERATION")
print("=" * 55)
examples = [
{
"name": "Ocean Storm (High Motion)",
"command": '''curl -X POST "http://localhost:8000/generate-video-from-prompt" \\
-H "Content-Type: application/json" \\
-d '{
"image_prompt": "Powerful ocean waves crashing against jagged rocks with storm clouds",
"duration": 10,
"voice_type": "onyx",
"style": "dramatic"
}\'''''
},
{
"name": "Forest Breeze (Organic Motion)",
"command": '''curl -X POST "http://localhost:8000/generate-video-from-prompt" \\
-H "Content-Type: application/json" \\
-d '{
"image_prompt": "Ancient forest with tall trees and golden sunlight filtering through",
"duration": 10,
"voice_type": "shimmer",
"style": "meditative"
}\'''''
},
{
"name": "Waterfall Cascade (Fluid Motion)",
"command": '''curl -X POST "http://localhost:8000/generate-video-from-prompt" \\
-H "Content-Type: application/json" \\
-d '{
"image_prompt": "Majestic waterfall cascading into a crystal clear pool with mist",
"duration": 10,
"voice_type": "nova",
"style": "descriptive"
}\'''''
}
]
for example in examples:
print(f"\n# {example['name']}")
print(example['command'])
print("\nπ― These examples will generate videos with:")
print("β’ Enhanced motion based on scene type")
print("β’ NO text or letters in the video")
print("β’ Cinematic camera movement")
print("β’ Natural element animation")
print("β’ Professional audio narration")
if __name__ == "__main__":
print("π Starting Dynamic Video Generation Tests...")
print("This will test enhanced motion and cinematic movement.")
print()
# Run dynamic scene tests
test_dynamic_scenes()
# Show CURL examples
show_curl_examples()
print("\nπ Dynamic video generation testing complete!")
print("Videos should now have significantly more motion and visual dynamics!")