-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.py
More file actions
218 lines (179 loc) · 6.97 KB
/
install.py
File metadata and controls
218 lines (179 loc) · 6.97 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
#!/usr/bin/env python3
"""
OpenCut Installer v1.0.0-beta
Cross-platform setup script. Run: python install.py
"""
import os
import sys
import shutil
import subprocess
import platform
VERS = "1.0.0-beta"
CEP_EXT = "com.opencut.panel"
WIN_CEP_DIR = os.path.expandvars(r"%APPDATA%\Adobe\CEP\extensions")
MAC_CEP_DIR = os.path.expanduser("~/Library/Application Support/Adobe/CEP/extensions")
LINUX_CEP_DIR = os.path.expanduser("~/.local/share/Adobe/CEP/extensions")
def banner():
print()
print(" ============================================")
print(f" OpenCut Installer v{VERS}")
print(" ============================================")
print()
def check_python():
v = sys.version_info
print(f" [OK] Python {v.major}.{v.minor}.{v.micro}")
if v < (3, 9):
print(" [!!] Python 3.9+ required. Please upgrade.")
sys.exit(1)
def check_ffmpeg():
if shutil.which("ffmpeg"):
try:
r = subprocess.run(["ffmpeg", "-version"], capture_output=True, text=True, timeout=5)
ver = r.stdout.split("\n")[0] if r.stdout else "unknown"
print(f" [OK] FFmpeg found: {ver[:60]}")
except Exception:
print(" [OK] FFmpeg found on PATH")
else:
print(" [!!] FFmpeg not found on PATH.")
print(" Download from https://ffmpeg.org/download.html")
print(" Or: winget install ffmpeg | brew install ffmpeg | apt install ffmpeg")
resp = input("\n Continue without FFmpeg? (y/n): ").strip().lower()
if resp != "y":
sys.exit(1)
def install_deps():
print("\n Installing Python dependencies...")
base_dir = os.path.dirname(os.path.abspath(__file__))
req_file = os.path.join(base_dir, "requirements.txt")
if os.path.exists(req_file):
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", req_file, "--quiet"])
else:
subprocess.check_call([sys.executable, "-m", "pip", "install",
"click>=8.0", "rich>=13.0", "flask>=3.0", "flask-cors>=4.0",
"faster-whisper>=1.0", "opencv-python-headless>=4.8",
"Pillow>=10.0", "numpy>=1.24", "--quiet"])
print(" [OK] Dependencies installed")
def install_cep_extension():
base_dir = os.path.dirname(os.path.abspath(__file__))
ext_src = os.path.join(base_dir, "extension", CEP_EXT)
if not os.path.isdir(ext_src):
print(" [!!] Extension source not found, skipping CEP install")
return
system = platform.system()
if system == "Windows":
cep_dir = WIN_CEP_DIR
elif system == "Darwin":
cep_dir = MAC_CEP_DIR
else:
cep_dir = LINUX_CEP_DIR
dest = os.path.join(cep_dir, CEP_EXT)
os.makedirs(cep_dir, exist_ok=True)
if os.path.exists(dest):
shutil.rmtree(dest)
print(" [OK] Removed previous extension install")
shutil.copytree(ext_src, dest)
print(f" [OK] Extension installed to: {dest}")
if system == "Windows":
enable_unsigned_extensions_windows()
def enable_unsigned_extensions_windows():
"""Set PlayerDebugMode registry key for unsigned CEP extensions."""
try:
import winreg
versions = ["11.0", "12.0", "13.0", "14.0", "15.0", "16.0", "17.0", "18.0"]
key_base = r"SOFTWARE\Adobe\CSXS"
count = 0
for ver in versions:
try:
key_path = f"{key_base}.{ver}"
key = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, key_path, 0, winreg.KEY_WRITE)
winreg.SetValueEx(key, "PlayerDebugMode", 0, winreg.REG_SZ, "1")
winreg.CloseKey(key)
count += 1
except Exception:
pass
if count:
print(f" [OK] PlayerDebugMode set for {count} CSXS versions")
else:
print(" [!!] Could not set PlayerDebugMode (try running as admin)")
except ImportError:
pass
def create_launcher():
base_dir = os.path.dirname(os.path.abspath(__file__))
system = platform.system()
if system == "Windows":
launcher = os.path.join(base_dir, "Start-OpenCut.bat")
with open(launcher, "w") as f:
f.write("@echo off\n")
f.write("echo.\n")
f.write(f"echo OpenCut Server v{VERS}\n")
f.write("echo ========================\n")
f.write("echo Starting on http://localhost:5679\n")
f.write("echo Close this window to stop.\n")
f.write("echo.\n")
f.write(f'"{sys.executable}" -m opencut.server\n')
f.write("pause\n")
print(f" [OK] Launcher created: {launcher}")
else:
launcher = os.path.join(base_dir, "start-opencut.sh")
with open(launcher, "w") as f:
f.write("#!/bin/bash\n")
f.write(f'echo "OpenCut Server v{VERS}"\n')
f.write('echo "Starting on http://localhost:5679"\n')
f.write(f'"{sys.executable}" -m opencut.server\n')
os.chmod(launcher, 0o755)
print(f" [OK] Launcher created: {launcher}")
def check_gpu():
try:
import torch
if torch.cuda.is_available():
name = torch.cuda.get_device_name(0)
vram = torch.cuda.get_device_properties(0).total_mem / (1024**3)
print(f" [OK] CUDA GPU: {name} ({vram:.1f}GB VRAM)")
else:
print(" [--] No CUDA GPU detected. AI features will use CPU (slower).")
print(" For GPU: pip install torch --index-url https://download.pytorch.org/whl/cu121")
except ImportError:
print(" [--] PyTorch not installed. AI features unavailable until installed.")
def verify():
print("\n Verifying installation...")
errors = []
try:
import flask
print(f" [OK] Flask {flask.__version__}")
except ImportError:
errors.append("flask")
try:
from faster_whisper import WhisperModel
print(" [OK] faster-whisper")
except ImportError:
print(" [--] faster-whisper not available (captions won't work)")
try:
import cv2
print(f" [OK] OpenCV {cv2.__version__}")
except ImportError:
print(" [--] OpenCV not available (some video effects limited)")
if errors:
print(f"\n [!!] Missing critical deps: {', '.join(errors)}")
return False
print("\n [OK] Installation verified successfully!")
return True
def main():
banner()
check_python()
check_ffmpeg()
install_deps()
install_cep_extension()
create_launcher()
check_gpu()
verify()
print()
print(" ============================================")
print(" Installation complete!")
print(" ============================================")
print()
print(" Next steps:")
print(" 1. Run Start-OpenCut.bat (or: python -m opencut.server)")
print(" 2. Open Premiere Pro > Window > Extensions > OpenCut")
print(" 3. Select a clip and start editing!")
print()
if __name__ == "__main__":
main()