-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
183 lines (146 loc) · 4.87 KB
/
setup.py
File metadata and controls
183 lines (146 loc) · 4.87 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
#!/usr/bin/env python3
"""
Installation and Setup Helper
"""
import os
import sys
import subprocess
from pathlib import Path
def check_python():
"""检查Python版本"""
if sys.version_info < (3, 7):
print("❌ Python 3.7+ is required")
return False
print(f"✅ Python {sys.version.split()[0]} found")
return True
def install_dependencies():
"""安装Python依赖"""
try:
print("📦 Installing Python dependencies...")
subprocess.run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"],
check=True)
print("✅ Dependencies installed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Failed to install dependencies: {e}")
return False
def check_mlt():
"""检查MLT Framework"""
mlt_paths = [
"/Applications/kdenlive.app/Contents/MacOS/melt",
]
for path in mlt_paths:
if os.path.exists(path):
print(f"✅ MLT found at {path}")
return path
# 检查系统PATH
try:
result = subprocess.run(["melt", "--version"],
capture_output=True, text=True)
if result.returncode == 0:
print("✅ MLT found in system PATH")
return "melt"
except FileNotFoundError:
pass
print("❌ MLT Framework not found")
print(" Please install MLT:")
print(" - macOS: brew install mlt")
print(" - Ubuntu: sudo apt-get install melt")
print(" - Or download from: https://www.mltframework.org/")
return None
def create_directories():
"""创建必要的目录"""
directories = [
"assets",
"effects/shake",
"effects/zoom",
"effects/blur",
"effects/transition",
"effects/glitch",
"effects/color",
"previews",
"templates"
]
for directory in directories:
Path(directory).mkdir(parents=True, exist_ok=True)
print("✅ Directories created")
def create_sample_assets():
"""创建示例素材"""
try:
from src.preview_generator import PreviewGenerator
generator = PreviewGenerator(".")
generator.create_sample_assets()
print("✅ Sample assets created")
except Exception as e:
print(f"⚠️ Could not create sample assets: {e}")
def generate_sample_effects():
"""生成示例特效"""
try:
from src.effect_generator import EffectGenerator
generator = EffectGenerator(".")
styles = ['shake', 'zoom', 'blur', 'transition', 'glitch', 'color']
total = 0
for style in styles:
files = generator.generate_effects(style, 2) # 每种风格生成2个示例
total += len(files)
print(f" Generated {len(files)} {style} effects")
print(f"✅ Generated {total} sample effects")
except Exception as e:
print(f"⚠️ Could not generate sample effects: {e}")
def create_env_file():
"""创建环境配置文件"""
env_file = Path(".env")
if not env_file.exists():
mlt_path = check_mlt()
if mlt_path:
content = f"""# Kdenlive Effect Generator Configuration
MELT_PATH={mlt_path}
PROJECT_NAME=Kdenlive Effect Generator
DEBUG=true
PREVIEW_WIDTH=1080
PREVIEW_HEIGHT=1920
PREVIEW_DURATION=5
PREVIEW_FPS=25
WEB_HOST=localhost
WEB_PORT=5000
"""
with open(env_file, 'w') as f:
f.write(content)
print("✅ Environment file created")
def main():
print("🎬 Kdenlive Effect Generator Setup")
print("=" * 40)
# 检查Python版本
if not check_python():
sys.exit(1)
# 安装依赖
if not install_dependencies():
sys.exit(1)
# 检查MLT
mlt_path = check_mlt()
# 创建目录
create_directories()
# 创建环境文件
create_env_file()
# 创建示例素材
create_sample_assets()
# 生成示例特效
generate_sample_effects()
print("\n🎉 Setup completed successfully!")
print("\nNext steps:")
print("1. Generate effects: python3 main.py generate --style shake --count 5")
print("2. Generate previews: python3 main.py preview --style shake")
print("3. Start web server: python3 main.py web")
print("4. Open browser: http://localhost:5000")
# 询问是否启动Web服务器
try:
response = input("\n🌐 Start web server now? (y/n): ").lower().strip()
if response in ['y', 'yes']:
print("🌐 Starting web server...")
from src.web_server import EffectPreviewServer
server = EffectPreviewServer(".")
server.run()
except KeyboardInterrupt:
print("\n👋 Setup complete. You can start the web server later with: python3 main.py web")
if __name__ == "__main__":
main()