-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo_effects_examples.py
More file actions
455 lines (393 loc) Β· 15.5 KB
/
video_effects_examples.py
File metadata and controls
455 lines (393 loc) Β· 15.5 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
#!/usr/bin/env python3
"""
Video Effects Examples
This script demonstrates the comprehensive video effects system that can add
visual effects during video processing using FFmpeg.
"""
import json
import requests
import time
from typing import Dict, Any, List
def test_video_effects_system():
"""Test the video effects system with various effect combinations."""
print("β¨ Video Effects System Test")
print("=" * 60)
print()
# Test scenarios with different effect combinations
effects_test_scenarios = [
{
"name": "Cinematic Ocean Scene",
"image_prompt": "A dramatic ocean scene with powerful waves at sunset",
"motion_intensity": "cinematic",
"effects": ["cinematic", "dramatic", "hdr"],
"effects_intensity": "strong",
"duration": 8,
"description": "Epic ocean with cinematic color grading and HDR effects"
},
{
"name": "Vibrant Forest with Glow",
"image_prompt": "A magical forest with ancient trees and mystical atmosphere",
"motion_intensity": "dynamic",
"effects": ["vibrant", "glow", "warm"],
"effects_intensity": "moderate",
"duration": 6,
"description": "Enchanted forest with vibrant colors and magical glow"
},
{
"name": "Retro City Scene",
"image_prompt": "A futuristic city street with neon lights and rain",
"motion_intensity": "dynamic",
"effects": ["cyberpunk", "neon", "rain"],
"effects_intensity": "strong",
"duration": 5,
"description": "Cyberpunk city with neon effects and rain"
},
{
"name": "Soft Mountain Landscape",
"image_prompt": "A serene mountain lake reflecting snow-capped peaks",
"motion_intensity": "subtle",
"effects": ["soft", "vignette", "film_grain"],
"effects_intensity": "subtle",
"duration": 10,
"description": "Peaceful mountain scene with soft film-like effects"
},
{
"name": "Instagram-Style Garden",
"image_prompt": "A beautiful garden with blooming flowers and butterflies",
"motion_intensity": "moderate",
"effects": ["instagram", "saturation", "brightness"],
"effects_intensity": "moderate",
"duration": 5,
"description": "Social media ready garden with enhanced colors"
}
]
results = []
for i, scenario in enumerate(effects_test_scenarios, 1):
print(f"β¨ Test {i}: {scenario['name']}")
print(f" Scene: {scenario['image_prompt']}")
print(f" Motion: {scenario['motion_intensity']}")
print(f" Effects: {scenario['effects']}")
print(f" Intensity: {scenario['effects_intensity']}")
print(f" Description: {scenario['description']}")
print()
# Test with preview mode first
print(" π Testing with preview mode...")
preview_result = test_effects_preview(scenario)
if preview_result:
print(" β
Preview generated successfully")
# Show what effects would be applied
if 'effects_info' in preview_result:
effects_info = preview_result['effects_info']
print(f" π¨ Effects to apply: {effects_info.get('effects', [])}")
print(f" β‘ Effects intensity: {effects_info.get('intensity', 'N/A')}")
else:
print(" β Preview failed")
results.append({
"scenario": scenario,
"preview_result": preview_result
})
print()
print("-" * 60)
print()
# Save results
timestamp = int(time.time())
results_file = f"video_effects_test_results_{timestamp}.json"
with open(results_file, 'w') as f:
json.dump(results, f, indent=2, ensure_ascii=False)
print(f"π Results saved to: {results_file}")
return results
def test_effects_preview(scenario: Dict[str, Any]) -> Dict[Any, Any]:
"""Test the effects preview for a specific scenario."""
try:
payload = {
"image_prompt": scenario["image_prompt"],
"motion_intensity": scenario["motion_intensity"],
"duration": scenario["duration"],
"effects": scenario["effects"],
"effects_intensity": scenario["effects_intensity"],
"preview_only": True
}
response = requests.post("http://localhost:8000/generate-video-from-prompt", json=payload)
if response.status_code == 200:
result = response.json()
# Add effects info to result for testing
if 'effects' in scenario:
result['effects_info'] = {
'effects': scenario['effects'],
'intensity': scenario['effects_intensity']
}
return result
else:
print(f" β API request failed: {response.status_code}")
return None
except Exception as e:
print(f" β Request failed: {e}")
return None
def demonstrate_effect_categories():
"""Demonstrate different categories of video effects."""
print("\nπ¨ Video Effects Categories")
print("=" * 60)
effect_categories = {
"Color & Brightness": [
"brightness", "contrast", "saturation", "vibrant",
"warm", "cool", "vintage", "sepia"
],
"Artistic": [
"oil_painting", "sketch", "emboss", "sharpen",
"glow", "neon"
],
"Color Grading": [
"cinematic", "dramatic", "soft", "hdr",
"film_grain", "film_look"
],
"Blur & Focus": [
"blur", "gaussian_blur", "motion_blur",
"radial_blur", "depth_blur"
],
"Lighting": [
"vignette", "lens_flare", "light_leak", "god_rays"
],
"Creative": [
"kaleidoscope", "mirror", "pixelate", "retro", "cyberpunk"
],
"Weather": [
"rain", "snow", "fog", "sunset"
],
"Professional": [
"broadcast", "instagram", "tiktok"
],
"Time Effects": [
"slow_motion", "fast_motion", "zoom_in", "zoom_out"
]
}
for category, effects in effect_categories.items():
print(f"\n㪠{category}:")
for effect in effects:
print(f" β’ {effect}")
print(f"\nπ Total Effects Available: {sum(len(effects) for effects in effect_categories.values())}")
def test_effects_intensity_comparison():
"""Compare the same effects at different intensity levels."""
print("\nβ‘ Effects Intensity Comparison")
print("=" * 60)
base_scenario = {
"image_prompt": "A beautiful sunset over a calm lake with mountains",
"motion_intensity": "moderate",
"effects": ["cinematic", "vibrant", "warm"],
"duration": 5
}
intensities = ["subtle", "moderate", "strong"]
print(f"Base Scene: {base_scenario['image_prompt']}")
print(f"Effects: {base_scenario['effects']}")
print()
for intensity in intensities:
print(f"ποΈ Testing {intensity.upper()} Intensity:")
test_payload = {
**base_scenario,
"effects_intensity": intensity,
"preview_only": True
}
try:
response = requests.post("http://localhost:8000/generate-video-from-prompt", json=test_payload)
if response.status_code == 200:
result = response.json()
print(f" Effects: {test_payload['effects']}")
print(f" Intensity: {intensity}")
print(" β
Success")
else:
print(f" β Failed: {response.status_code}")
except Exception as e:
print(f" β Error: {e}")
print()
def create_effects_combination_examples():
"""Create examples of effective effect combinations."""
print("\nπ Recommended Effects Combinations")
print("=" * 60)
combinations = [
{
"name": "Professional Cinematic",
"effects": ["cinematic", "dramatic", "film_grain"],
"use_case": "High-end professional videos",
"best_intensity": "strong"
},
{
"name": "Social Media Ready",
"effects": ["instagram", "saturation", "brightness"],
"use_case": "Instagram, TikTok content",
"best_intensity": "moderate"
},
{
"name": "Dreamy Artistic",
"effects": ["soft", "glow", "vignette"],
"use_case": "Artistic, romantic content",
"best_intensity": "moderate"
},
{
"name": "Cyberpunk Future",
"effects": ["cyberpunk", "neon", "contrast"],
"use_case": "Sci-fi, futuristic themes",
"best_intensity": "strong"
},
{
"name": "Vintage Film",
"effects": ["vintage", "film_grain", "warm"],
"use_case": "Retro, nostalgic content",
"best_intensity": "moderate"
},
{
"name": "Nature Documentary",
"effects": ["hdr", "sharpen", "vibrant"],
"use_case": "Wildlife, nature videos",
"best_intensity": "strong"
},
{
"name": "Meditation & Wellness",
"effects": ["soft", "warm", "vignette"],
"use_case": "Relaxation, wellness content",
"best_intensity": "subtle"
},
{
"name": "Action & Energy",
"effects": ["dramatic", "contrast", "saturation"],
"use_case": "Sports, action content",
"best_intensity": "strong"
}
]
for combo in combinations:
print(f"π¨ {combo['name']}:")
print(f" Effects: {', '.join(combo['effects'])}")
print(f" Use Case: {combo['use_case']}")
print(f" Best Intensity: {combo['best_intensity']}")
print()
def test_api_health():
"""Check if the API server is running and healthy."""
try:
response = requests.get("http://localhost:8000/health")
if response.status_code == 200:
print("β
API server is healthy")
return True
else:
print(f"β οΈ API server returned status: {response.status_code}")
return False
except requests.exceptions.ConnectionError:
print("β Cannot connect to API server at http://localhost:8000")
print(" Please start the server with: python run_api.py")
return False
except Exception as e:
print(f"β API health check failed: {e}")
return False
def demonstrate_effects_api_usage():
"""Show how to use the effects API."""
print("\nπ§ Effects API Usage Examples")
print("=" * 60)
print("\nπ CURL Examples:")
print()
# Basic effects example
print("π¨ Basic Effects Example:")
print("```bash")
print('curl -X POST "http://localhost:8000/generate-video-from-prompt" \\')
print(' -H "Content-Type: application/json" \\')
print(' -d \'{')
print(' "image_prompt": "A beautiful forest scene with sunlight",')
print(' "motion_intensity": "dynamic",')
print(' "effects": ["cinematic", "vibrant", "glow"],')
print(' "effects_intensity": "moderate",')
print(' "duration": 6')
print(' }\'')
print("```")
print()
# Professional effects example
print("π¬ Professional Effects Example:")
print("```bash")
print('curl -X POST "http://localhost:8000/generate-video-from-prompt" \\')
print(' -H "Content-Type: application/json" \\')
print(' -d \'{')
print(' "image_prompt": "An epic mountain landscape during golden hour",')
print(' "motion_intensity": "cinematic",')
print(' "effects": ["dramatic", "hdr", "film_grain"],')
print(' "effects_intensity": "strong",')
print(' "duration": 10,')
print(' "voice_type": "onyx",')
print(' "style": "dramatic",')
print(' "merge_audio": true')
print(' }\'')
print("```")
print()
# Social media effects example
print("π± Social Media Effects Example:")
print("```bash")
print('curl -X POST "http://localhost:8000/generate-video-from-prompt" \\')
print(' -H "Content-Type: application/json" \\')
print(' -d \'{')
print(' "image_prompt": "A trendy urban cafe with modern design",')
print(' "motion_intensity": "dynamic",')
print(' "effects": ["instagram", "saturation", "brightness"],')
print(' "effects_intensity": "moderate",')
print(' "duration": 5,')
print(' "ratio": "1024:1024"')
print(' }\'')
print("```")
print()
print("π Python Examples:")
print()
print("```python")
print("import requests")
print()
print("# Professional cinematic video with effects")
print("response = requests.post('http://localhost:8000/generate-video-from-prompt', json={")
print(" 'image_prompt': 'A majestic waterfall in a lush jungle',")
print(" 'motion_intensity': 'cinematic',")
print(" 'effects': ['cinematic', 'dramatic', 'hdr'],")
print(" 'effects_intensity': 'strong',")
print(" 'duration': 8,")
print(" 'merge_audio': True,")
print(" 'voice_type': 'nova',")
print(" 'style': 'dramatic'")
print("})")
print()
print("result = response.json()")
print("print(f'Video URL: {result[\"video_url\"]}')")
print("print(f'Effects Applied: {result.get(\"effects_applied\", [])}')")
print("```")
if __name__ == "__main__":
print("π Starting Video Effects System Tests")
print("=" * 60)
# Check API health
if not test_api_health():
exit(1)
print()
# Demonstrate effect categories
demonstrate_effect_categories()
# Show recommended combinations
create_effects_combination_examples()
# Show API usage
demonstrate_effects_api_usage()
# Run effects tests
print()
results = test_video_effects_system()
# Test intensity comparison
test_effects_intensity_comparison()
print("\nπ Video Effects Testing Complete!")
print("\n⨠Key Effects Features:")
print("β’ 40+ professional video effects available")
print("β’ 3 intensity levels: subtle, moderate, strong")
print("β’ 9 effect categories: Color, Artistic, Creative, etc.")
print("β’ Real-time FFmpeg processing during generation")
print("β’ Perfect integration with motion and audio systems")
print("\nπ¨ Effect Categories:")
print("β’ Color & Brightness: brightness, contrast, saturation, vibrant")
print("β’ Artistic: oil_painting, sketch, emboss, glow, neon")
print("β’ Professional: cinematic, dramatic, hdr, film_look")
print("β’ Creative: kaleidoscope, mirror, pixelate, cyberpunk")
print("β’ Weather: rain, snow, fog, sunset")
print("β’ Time Effects: slow_motion, fast_motion, zoom effects")
print("\nπ Recommended Combinations:")
print("β’ Professional: ['cinematic', 'dramatic', 'film_grain']")
print("β’ Social Media: ['instagram', 'saturation', 'brightness']")
print("β’ Artistic: ['soft', 'glow', 'vignette']")
print("β’ Cyberpunk: ['cyberpunk', 'neon', 'contrast']")
print("β’ Vintage: ['vintage', 'film_grain', 'warm']")
print("\nβ‘ Usage Tips:")
print("β’ Start with 1-3 effects for best results")
print("β’ Match effects intensity to content style")
print("β’ Combine with motion_intensity for full impact")
print("β’ Use preview_only=true to test combinations")