visualkit 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- visualkit/__init__.py +6 -0
- visualkit/__main__.py +5 -0
- visualkit/config.py +26 -0
- visualkit/editor.py +183 -0
- visualkit/enums.py +7 -0
- visualkit/media_element.py +1356 -0
- visualkit/project_creator.py +130 -0
- visualkit/text_element.py +277 -0
- visualkit/timeline.py +47 -0
- visualkit/transitions.py +595 -0
- visualkit/utils.py +5 -0
- visualkit-0.0.1.dist-info/METADATA +53 -0
- visualkit-0.0.1.dist-info/RECORD +17 -0
- visualkit-0.0.1.dist-info/WHEEL +5 -0
- visualkit-0.0.1.dist-info/licenses/AUTHORS.rst +4 -0
- visualkit-0.0.1.dist-info/licenses/LICENSE +9 -0
- visualkit-0.0.1.dist-info/top_level.txt +1 -0
visualkit/transitions.py
ADDED
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
import cv2
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from visualkit.utils import logger
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TransitionElement:
|
|
10
|
+
def __init__(self, duration: float, transition_type: str = "crossfade"):
|
|
11
|
+
if duration <= 0:
|
|
12
|
+
raise ValueError("Transition duration must be positive")
|
|
13
|
+
self.duration = duration
|
|
14
|
+
self.transition_type = transition_type
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def get_available_transitions():
|
|
18
|
+
"""Return a list of all available transitions"""
|
|
19
|
+
return [
|
|
20
|
+
"none",
|
|
21
|
+
"crossfade",
|
|
22
|
+
"slide_left",
|
|
23
|
+
"slide_right",
|
|
24
|
+
"slide_up",
|
|
25
|
+
"slide_down",
|
|
26
|
+
"slide_diagonal", # little slow
|
|
27
|
+
"wipe_left",
|
|
28
|
+
"wipe_right",
|
|
29
|
+
"wipe_up",
|
|
30
|
+
"wipe_down",
|
|
31
|
+
"wipe_center_out",
|
|
32
|
+
"wipe_center_in",
|
|
33
|
+
"push_left",
|
|
34
|
+
"push_right",
|
|
35
|
+
"push_up",
|
|
36
|
+
"push_down",
|
|
37
|
+
"zoom_in",
|
|
38
|
+
"zoom_out",
|
|
39
|
+
"scale_up",
|
|
40
|
+
"scale_down",
|
|
41
|
+
# "split_vertical", # not working
|
|
42
|
+
# "split_horizontal", # not working
|
|
43
|
+
"venetian_blinds",
|
|
44
|
+
"vertical_blinds",
|
|
45
|
+
"circle_in",
|
|
46
|
+
"circle_out",
|
|
47
|
+
"fade_to_black",
|
|
48
|
+
"fade_to_white",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
def apply(
|
|
52
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, timestamp: float
|
|
53
|
+
) -> np.ndarray:
|
|
54
|
+
if prev_frame.shape != next_frame.shape:
|
|
55
|
+
logger.warning("Frame shape mismatch in transition, resizing next frame")
|
|
56
|
+
next_frame = cv2.resize(
|
|
57
|
+
next_frame,
|
|
58
|
+
(prev_frame.shape[1], prev_frame.shape[0]),
|
|
59
|
+
interpolation=cv2.INTER_AREA,
|
|
60
|
+
)
|
|
61
|
+
progress = min(1.0, max(0.0, timestamp / self.duration))
|
|
62
|
+
|
|
63
|
+
# Existing transitions
|
|
64
|
+
if self.transition_type == "crossfade":
|
|
65
|
+
return self._crossfade(prev_frame, next_frame, progress)
|
|
66
|
+
if self.transition_type == "slide_left":
|
|
67
|
+
return self._slide_left(prev_frame, next_frame, progress)
|
|
68
|
+
|
|
69
|
+
# New slide transitions
|
|
70
|
+
if self.transition_type == "slide_right":
|
|
71
|
+
return self._slide_right(prev_frame, next_frame, progress)
|
|
72
|
+
if self.transition_type == "slide_up":
|
|
73
|
+
return self._slide_up(prev_frame, next_frame, progress)
|
|
74
|
+
if self.transition_type == "slide_down":
|
|
75
|
+
return self._slide_down(prev_frame, next_frame, progress)
|
|
76
|
+
if self.transition_type == "slide_diagonal":
|
|
77
|
+
return self._slide_diagonal(prev_frame, next_frame, progress)
|
|
78
|
+
|
|
79
|
+
# Wipe transitions
|
|
80
|
+
if self.transition_type == "wipe_left":
|
|
81
|
+
return self._wipe_left(prev_frame, next_frame, progress)
|
|
82
|
+
if self.transition_type == "wipe_right":
|
|
83
|
+
return self._wipe_right(prev_frame, next_frame, progress)
|
|
84
|
+
if self.transition_type == "wipe_up":
|
|
85
|
+
return self._wipe_up(prev_frame, next_frame, progress)
|
|
86
|
+
if self.transition_type == "wipe_down":
|
|
87
|
+
return self._wipe_down(prev_frame, next_frame, progress)
|
|
88
|
+
if self.transition_type == "wipe_center_out":
|
|
89
|
+
return self._wipe_center_out(prev_frame, next_frame, progress)
|
|
90
|
+
if self.transition_type == "wipe_center_in":
|
|
91
|
+
return self._wipe_center_in(prev_frame, next_frame, progress)
|
|
92
|
+
|
|
93
|
+
# Push transitions
|
|
94
|
+
if self.transition_type == "push_left":
|
|
95
|
+
return self._push_left(prev_frame, next_frame, progress)
|
|
96
|
+
if self.transition_type == "push_right":
|
|
97
|
+
return self._push_right(prev_frame, next_frame, progress)
|
|
98
|
+
if self.transition_type == "push_up":
|
|
99
|
+
return self._push_up(prev_frame, next_frame, progress)
|
|
100
|
+
if self.transition_type == "push_down":
|
|
101
|
+
return self._push_down(prev_frame, next_frame, progress)
|
|
102
|
+
|
|
103
|
+
# Zoom/Scale transitions
|
|
104
|
+
if self.transition_type == "zoom_in":
|
|
105
|
+
return self._zoom_in(prev_frame, next_frame, progress)
|
|
106
|
+
if self.transition_type == "zoom_out":
|
|
107
|
+
return self._zoom_out(prev_frame, next_frame, progress)
|
|
108
|
+
if self.transition_type == "scale_up":
|
|
109
|
+
return self._scale_up(prev_frame, next_frame, progress)
|
|
110
|
+
if self.transition_type == "scale_down":
|
|
111
|
+
return self._scale_down(prev_frame, next_frame, progress)
|
|
112
|
+
|
|
113
|
+
# Split screen transitions
|
|
114
|
+
if self.transition_type == "split_vertical":
|
|
115
|
+
return self._split_vertical(prev_frame, next_frame, progress)
|
|
116
|
+
if self.transition_type == "split_horizontal":
|
|
117
|
+
return self._split_horizontal(prev_frame, next_frame, progress)
|
|
118
|
+
if self.transition_type == "venetian_blinds":
|
|
119
|
+
return self._venetian_blinds(prev_frame, next_frame, progress)
|
|
120
|
+
if self.transition_type == "vertical_blinds":
|
|
121
|
+
return self._vertical_blinds(prev_frame, next_frame, progress)
|
|
122
|
+
|
|
123
|
+
# Circular transitions
|
|
124
|
+
if self.transition_type == "circle_in":
|
|
125
|
+
return self._circle_in(prev_frame, next_frame, progress)
|
|
126
|
+
if self.transition_type == "circle_out":
|
|
127
|
+
return self._circle_out(prev_frame, next_frame, progress)
|
|
128
|
+
|
|
129
|
+
# Fade variations
|
|
130
|
+
if self.transition_type == "fade_to_black":
|
|
131
|
+
return self._fade_to_black(prev_frame, next_frame, progress)
|
|
132
|
+
if self.transition_type == "fade_to_white":
|
|
133
|
+
return self._fade_to_white(prev_frame, next_frame, progress)
|
|
134
|
+
|
|
135
|
+
return next_frame
|
|
136
|
+
|
|
137
|
+
def _crossfade(
|
|
138
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
139
|
+
) -> np.ndarray:
|
|
140
|
+
prev_float = prev_frame.astype(np.float32)
|
|
141
|
+
next_float = next_frame.astype(np.float32)
|
|
142
|
+
result = prev_float * (1 - progress) + next_float * progress
|
|
143
|
+
return np.clip(result, 0, 255).astype(np.uint8)
|
|
144
|
+
|
|
145
|
+
def _slide_left(
|
|
146
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
147
|
+
) -> np.ndarray:
|
|
148
|
+
h, w = prev_frame.shape[:2]
|
|
149
|
+
split_point = int(w * progress)
|
|
150
|
+
result = prev_frame.copy()
|
|
151
|
+
if split_point > 0:
|
|
152
|
+
result[:, :split_point] = next_frame[:, :split_point]
|
|
153
|
+
return result
|
|
154
|
+
|
|
155
|
+
# New slide transitions
|
|
156
|
+
def _slide_right(
|
|
157
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
158
|
+
) -> np.ndarray:
|
|
159
|
+
h, w = prev_frame.shape[:2]
|
|
160
|
+
split_point = int(w * (1 - progress))
|
|
161
|
+
result = prev_frame.copy()
|
|
162
|
+
if split_point < w:
|
|
163
|
+
result[:, split_point:] = next_frame[:, split_point:]
|
|
164
|
+
return result
|
|
165
|
+
|
|
166
|
+
def _slide_up(
|
|
167
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
168
|
+
) -> np.ndarray:
|
|
169
|
+
h, w = prev_frame.shape[:2]
|
|
170
|
+
split_point = int(h * progress)
|
|
171
|
+
result = prev_frame.copy()
|
|
172
|
+
if split_point > 0:
|
|
173
|
+
result[:split_point, :] = next_frame[:split_point, :]
|
|
174
|
+
return result
|
|
175
|
+
|
|
176
|
+
def _slide_down(
|
|
177
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
178
|
+
) -> np.ndarray:
|
|
179
|
+
h, w = prev_frame.shape[:2]
|
|
180
|
+
split_point = int(h * (1 - progress))
|
|
181
|
+
result = prev_frame.copy()
|
|
182
|
+
if split_point < h:
|
|
183
|
+
result[split_point:, :] = next_frame[split_point:, :]
|
|
184
|
+
return result
|
|
185
|
+
|
|
186
|
+
def _slide_diagonal(
|
|
187
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
188
|
+
) -> np.ndarray:
|
|
189
|
+
h, w = prev_frame.shape[:2]
|
|
190
|
+
result = prev_frame.copy()
|
|
191
|
+
|
|
192
|
+
# Create diagonal mask
|
|
193
|
+
for y in range(h):
|
|
194
|
+
for x in range(w):
|
|
195
|
+
# Diagonal line from top-left to bottom-right
|
|
196
|
+
diagonal_progress = (x + y) / (w + h - 2)
|
|
197
|
+
if diagonal_progress <= progress:
|
|
198
|
+
result[y, x] = next_frame[y, x]
|
|
199
|
+
|
|
200
|
+
return result
|
|
201
|
+
|
|
202
|
+
# Wipe transitions
|
|
203
|
+
def _wipe_left(
|
|
204
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
205
|
+
) -> np.ndarray:
|
|
206
|
+
h, w = prev_frame.shape[:2]
|
|
207
|
+
wipe_point = int(w * (1 - progress))
|
|
208
|
+
result = next_frame.copy()
|
|
209
|
+
if wipe_point > 0:
|
|
210
|
+
result[:, :wipe_point] = prev_frame[:, :wipe_point]
|
|
211
|
+
return result
|
|
212
|
+
|
|
213
|
+
def _wipe_right(
|
|
214
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
215
|
+
) -> np.ndarray:
|
|
216
|
+
h, w = prev_frame.shape[:2]
|
|
217
|
+
wipe_point = int(w * progress)
|
|
218
|
+
result = next_frame.copy()
|
|
219
|
+
if wipe_point < w:
|
|
220
|
+
result[:, wipe_point:] = prev_frame[:, wipe_point:]
|
|
221
|
+
return result
|
|
222
|
+
|
|
223
|
+
def _wipe_up(
|
|
224
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
225
|
+
) -> np.ndarray:
|
|
226
|
+
h, w = prev_frame.shape[:2]
|
|
227
|
+
wipe_point = int(h * (1 - progress))
|
|
228
|
+
result = next_frame.copy()
|
|
229
|
+
if wipe_point > 0:
|
|
230
|
+
result[:wipe_point, :] = prev_frame[:wipe_point, :]
|
|
231
|
+
return result
|
|
232
|
+
|
|
233
|
+
def _wipe_down(
|
|
234
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
235
|
+
) -> np.ndarray:
|
|
236
|
+
h, w = prev_frame.shape[:2]
|
|
237
|
+
wipe_point = int(h * progress)
|
|
238
|
+
result = next_frame.copy()
|
|
239
|
+
if wipe_point < h:
|
|
240
|
+
result[wipe_point:, :] = prev_frame[wipe_point:, :]
|
|
241
|
+
return result
|
|
242
|
+
|
|
243
|
+
def _wipe_center_out(
|
|
244
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
245
|
+
) -> np.ndarray:
|
|
246
|
+
h, w = prev_frame.shape[:2]
|
|
247
|
+
center_x, center_y = w // 2, h // 2
|
|
248
|
+
max_radius = int(math.sqrt(center_x**2 + center_y**2) * progress)
|
|
249
|
+
|
|
250
|
+
result = prev_frame.copy()
|
|
251
|
+
|
|
252
|
+
# Create circular mask
|
|
253
|
+
y, x = np.ogrid[:h, :w]
|
|
254
|
+
mask = (x - center_x) ** 2 + (y - center_y) ** 2 <= max_radius**2
|
|
255
|
+
result[mask] = next_frame[mask]
|
|
256
|
+
|
|
257
|
+
return result
|
|
258
|
+
|
|
259
|
+
def _wipe_center_in(
|
|
260
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
261
|
+
) -> np.ndarray:
|
|
262
|
+
h, w = prev_frame.shape[:2]
|
|
263
|
+
center_x, center_y = w // 2, h // 2
|
|
264
|
+
max_radius = int(math.sqrt(center_x**2 + center_y**2))
|
|
265
|
+
current_radius = int(max_radius * (1 - progress))
|
|
266
|
+
|
|
267
|
+
result = next_frame.copy()
|
|
268
|
+
|
|
269
|
+
# Create circular mask
|
|
270
|
+
y, x = np.ogrid[:h, :w]
|
|
271
|
+
mask = (x - center_x) ** 2 + (y - center_y) ** 2 <= current_radius**2
|
|
272
|
+
result[mask] = prev_frame[mask]
|
|
273
|
+
|
|
274
|
+
return result
|
|
275
|
+
|
|
276
|
+
# Push transitions
|
|
277
|
+
def _push_left(
|
|
278
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
279
|
+
) -> np.ndarray:
|
|
280
|
+
h, w = prev_frame.shape[:2]
|
|
281
|
+
offset = int(w * progress)
|
|
282
|
+
result = np.zeros_like(prev_frame)
|
|
283
|
+
|
|
284
|
+
# Push previous frame to the left
|
|
285
|
+
if offset < w:
|
|
286
|
+
result[:, : w - offset] = prev_frame[:, offset:]
|
|
287
|
+
|
|
288
|
+
# Next frame comes from the right
|
|
289
|
+
if offset > 0:
|
|
290
|
+
result[:, w - offset :] = next_frame[:, :offset]
|
|
291
|
+
|
|
292
|
+
return result
|
|
293
|
+
|
|
294
|
+
def _push_right(
|
|
295
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
296
|
+
) -> np.ndarray:
|
|
297
|
+
h, w = prev_frame.shape[:2]
|
|
298
|
+
offset = int(w * progress)
|
|
299
|
+
result = np.zeros_like(prev_frame)
|
|
300
|
+
|
|
301
|
+
# Push previous frame to the right
|
|
302
|
+
if offset < w:
|
|
303
|
+
result[:, offset:] = prev_frame[:, : w - offset]
|
|
304
|
+
|
|
305
|
+
# Next frame comes from the left
|
|
306
|
+
if offset > 0:
|
|
307
|
+
result[:, :offset] = next_frame[:, w - offset :]
|
|
308
|
+
|
|
309
|
+
return result
|
|
310
|
+
|
|
311
|
+
def _push_up(
|
|
312
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
313
|
+
) -> np.ndarray:
|
|
314
|
+
h, w = prev_frame.shape[:2]
|
|
315
|
+
offset = int(h * progress)
|
|
316
|
+
result = np.zeros_like(prev_frame)
|
|
317
|
+
|
|
318
|
+
# Push previous frame up
|
|
319
|
+
if offset < h:
|
|
320
|
+
result[: h - offset, :] = prev_frame[offset:, :]
|
|
321
|
+
|
|
322
|
+
# Next frame comes from the bottom
|
|
323
|
+
if offset > 0:
|
|
324
|
+
result[h - offset :, :] = next_frame[:offset, :]
|
|
325
|
+
|
|
326
|
+
return result
|
|
327
|
+
|
|
328
|
+
def _push_down(
|
|
329
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
330
|
+
) -> np.ndarray:
|
|
331
|
+
h, w = prev_frame.shape[:2]
|
|
332
|
+
offset = int(h * progress)
|
|
333
|
+
result = np.zeros_like(prev_frame)
|
|
334
|
+
|
|
335
|
+
# Push previous frame down
|
|
336
|
+
if offset < h:
|
|
337
|
+
result[offset:, :] = prev_frame[: h - offset, :]
|
|
338
|
+
|
|
339
|
+
# Next frame comes from the top
|
|
340
|
+
if offset > 0:
|
|
341
|
+
result[:offset, :] = next_frame[h - offset :, :]
|
|
342
|
+
|
|
343
|
+
return result
|
|
344
|
+
|
|
345
|
+
# Zoom/Scale transitions
|
|
346
|
+
def _zoom_in(
|
|
347
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
348
|
+
) -> np.ndarray:
|
|
349
|
+
h, w = prev_frame.shape[:2]
|
|
350
|
+
|
|
351
|
+
# Scale next frame from small to full size
|
|
352
|
+
scale = progress
|
|
353
|
+
if scale <= 0:
|
|
354
|
+
return prev_frame
|
|
355
|
+
|
|
356
|
+
scaled_h = int(h * scale)
|
|
357
|
+
scaled_w = int(w * scale)
|
|
358
|
+
|
|
359
|
+
if scaled_h <= 0 or scaled_w <= 0:
|
|
360
|
+
return prev_frame
|
|
361
|
+
|
|
362
|
+
scaled_next = cv2.resize(next_frame, (scaled_w, scaled_h))
|
|
363
|
+
|
|
364
|
+
# Center the scaled frame
|
|
365
|
+
result = prev_frame.copy()
|
|
366
|
+
start_y = (h - scaled_h) // 2
|
|
367
|
+
start_x = (w - scaled_w) // 2
|
|
368
|
+
|
|
369
|
+
if start_y >= 0 and start_x >= 0:
|
|
370
|
+
result[start_y : start_y + scaled_h, start_x : start_x + scaled_w] = (
|
|
371
|
+
scaled_next
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
return result
|
|
375
|
+
|
|
376
|
+
def _zoom_out(
|
|
377
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
378
|
+
) -> np.ndarray:
|
|
379
|
+
h, w = prev_frame.shape[:2]
|
|
380
|
+
|
|
381
|
+
# Scale previous frame from full size to small
|
|
382
|
+
scale = 1 - progress
|
|
383
|
+
if scale <= 0:
|
|
384
|
+
return next_frame
|
|
385
|
+
|
|
386
|
+
scaled_h = int(h * scale)
|
|
387
|
+
scaled_w = int(w * scale)
|
|
388
|
+
|
|
389
|
+
if scaled_h <= 0 or scaled_w <= 0:
|
|
390
|
+
return next_frame
|
|
391
|
+
|
|
392
|
+
scaled_prev = cv2.resize(prev_frame, (scaled_w, scaled_h))
|
|
393
|
+
|
|
394
|
+
# Center the scaled frame over next frame
|
|
395
|
+
result = next_frame.copy()
|
|
396
|
+
start_y = (h - scaled_h) // 2
|
|
397
|
+
start_x = (w - scaled_w) // 2
|
|
398
|
+
|
|
399
|
+
if start_y >= 0 and start_x >= 0:
|
|
400
|
+
result[start_y : start_y + scaled_h, start_x : start_x + scaled_w] = (
|
|
401
|
+
scaled_prev
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
return result
|
|
405
|
+
|
|
406
|
+
def _scale_up(
|
|
407
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
408
|
+
) -> np.ndarray:
|
|
409
|
+
# Similar to zoom_in but with different easing
|
|
410
|
+
return self._zoom_in(prev_frame, next_frame, progress**0.5)
|
|
411
|
+
|
|
412
|
+
def _scale_down(
|
|
413
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
414
|
+
) -> np.ndarray:
|
|
415
|
+
# Similar to zoom_out but with different easing
|
|
416
|
+
return self._zoom_out(prev_frame, next_frame, progress**2)
|
|
417
|
+
|
|
418
|
+
# Split screen transitions
|
|
419
|
+
def _split_vertical(
|
|
420
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
421
|
+
) -> np.ndarray:
|
|
422
|
+
h, w = prev_frame.shape[:2]
|
|
423
|
+
center = w // 2
|
|
424
|
+
split_distance = int(w * progress * 0.5)
|
|
425
|
+
|
|
426
|
+
result = np.zeros_like(prev_frame)
|
|
427
|
+
|
|
428
|
+
# Left half moves left
|
|
429
|
+
left_end = max(0, center - split_distance)
|
|
430
|
+
if left_end > 0:
|
|
431
|
+
result[:, :left_end] = prev_frame[
|
|
432
|
+
:, split_distance : center + split_distance
|
|
433
|
+
]
|
|
434
|
+
|
|
435
|
+
# Right half moves right
|
|
436
|
+
right_start = min(w, center + split_distance)
|
|
437
|
+
if right_start < w:
|
|
438
|
+
result[:, right_start:] = prev_frame[
|
|
439
|
+
:, center - split_distance : center - split_distance + w - right_start
|
|
440
|
+
]
|
|
441
|
+
|
|
442
|
+
# Fill the gap with next frame
|
|
443
|
+
if split_distance > 0:
|
|
444
|
+
gap_start = max(0, center - split_distance)
|
|
445
|
+
gap_end = min(w, center + split_distance)
|
|
446
|
+
if gap_end > gap_start:
|
|
447
|
+
result[:, gap_start:gap_end] = next_frame[:, gap_start:gap_end]
|
|
448
|
+
|
|
449
|
+
return result
|
|
450
|
+
|
|
451
|
+
def _split_horizontal(
|
|
452
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
453
|
+
) -> np.ndarray:
|
|
454
|
+
h, w = prev_frame.shape[:2]
|
|
455
|
+
center = h // 2
|
|
456
|
+
split_distance = int(h * progress * 0.5)
|
|
457
|
+
|
|
458
|
+
result = np.zeros_like(prev_frame)
|
|
459
|
+
|
|
460
|
+
# Top half moves up
|
|
461
|
+
top_end = max(0, center - split_distance)
|
|
462
|
+
if top_end > 0:
|
|
463
|
+
result[:top_end, :] = prev_frame[
|
|
464
|
+
split_distance : center + split_distance, :
|
|
465
|
+
]
|
|
466
|
+
|
|
467
|
+
# Bottom half moves down
|
|
468
|
+
bottom_start = min(h, center + split_distance)
|
|
469
|
+
if bottom_start < h:
|
|
470
|
+
result[bottom_start:, :] = prev_frame[
|
|
471
|
+
center - split_distance : center - split_distance + h - bottom_start, :
|
|
472
|
+
]
|
|
473
|
+
|
|
474
|
+
# Fill the gap with next frame
|
|
475
|
+
if split_distance > 0:
|
|
476
|
+
gap_start = max(0, center - split_distance)
|
|
477
|
+
gap_end = min(h, center + split_distance)
|
|
478
|
+
if gap_end > gap_start:
|
|
479
|
+
result[gap_start:gap_end, :] = next_frame[gap_start:gap_end, :]
|
|
480
|
+
|
|
481
|
+
return result
|
|
482
|
+
|
|
483
|
+
def _venetian_blinds(
|
|
484
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
485
|
+
) -> np.ndarray:
|
|
486
|
+
h, w = prev_frame.shape[:2]
|
|
487
|
+
blind_count = 10 # Number of horizontal blinds
|
|
488
|
+
blind_height = h // blind_count
|
|
489
|
+
|
|
490
|
+
result = prev_frame.copy()
|
|
491
|
+
|
|
492
|
+
for i in range(blind_count):
|
|
493
|
+
start_row = i * blind_height
|
|
494
|
+
end_row = min((i + 1) * blind_height, h)
|
|
495
|
+
|
|
496
|
+
# Each blind opens at slightly different times
|
|
497
|
+
blind_progress = max(0, min(1, (progress - i * 0.05) / 0.7))
|
|
498
|
+
|
|
499
|
+
if blind_progress > 0:
|
|
500
|
+
reveal_height = int(blind_height * blind_progress)
|
|
501
|
+
if reveal_height > 0:
|
|
502
|
+
reveal_end = min(start_row + reveal_height, end_row)
|
|
503
|
+
result[start_row:reveal_end, :] = next_frame[
|
|
504
|
+
start_row:reveal_end, :
|
|
505
|
+
]
|
|
506
|
+
|
|
507
|
+
return result
|
|
508
|
+
|
|
509
|
+
def _vertical_blinds(
|
|
510
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
511
|
+
) -> np.ndarray:
|
|
512
|
+
h, w = prev_frame.shape[:2]
|
|
513
|
+
blind_count = 10 # Number of vertical blinds
|
|
514
|
+
blind_width = w // blind_count
|
|
515
|
+
|
|
516
|
+
result = prev_frame.copy()
|
|
517
|
+
|
|
518
|
+
for i in range(blind_count):
|
|
519
|
+
start_col = i * blind_width
|
|
520
|
+
end_col = min((i + 1) * blind_width, w)
|
|
521
|
+
|
|
522
|
+
# Each blind opens at slightly different times
|
|
523
|
+
blind_progress = max(0, min(1, (progress - i * 0.05) / 0.7))
|
|
524
|
+
|
|
525
|
+
if blind_progress > 0:
|
|
526
|
+
reveal_width = int(blind_width * blind_progress)
|
|
527
|
+
if reveal_width > 0:
|
|
528
|
+
reveal_end = min(start_col + reveal_width, end_col)
|
|
529
|
+
result[:, start_col:reveal_end] = next_frame[
|
|
530
|
+
:, start_col:reveal_end
|
|
531
|
+
]
|
|
532
|
+
|
|
533
|
+
return result
|
|
534
|
+
|
|
535
|
+
# Circular transitions
|
|
536
|
+
def _circle_in(
|
|
537
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
538
|
+
) -> np.ndarray:
|
|
539
|
+
h, w = prev_frame.shape[:2]
|
|
540
|
+
center_x, center_y = w // 2, h // 2
|
|
541
|
+
max_radius = math.sqrt(center_x**2 + center_y**2)
|
|
542
|
+
current_radius = max_radius * progress
|
|
543
|
+
|
|
544
|
+
result = prev_frame.copy()
|
|
545
|
+
|
|
546
|
+
# Create circular mask
|
|
547
|
+
y, x = np.ogrid[:h, :w]
|
|
548
|
+
mask = (x - center_x) ** 2 + (y - center_y) ** 2 <= current_radius**2
|
|
549
|
+
result[mask] = next_frame[mask]
|
|
550
|
+
|
|
551
|
+
return result
|
|
552
|
+
|
|
553
|
+
def _circle_out(
|
|
554
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
555
|
+
) -> np.ndarray:
|
|
556
|
+
h, w = prev_frame.shape[:2]
|
|
557
|
+
center_x, center_y = w // 2, h // 2
|
|
558
|
+
max_radius = math.sqrt(center_x**2 + center_y**2)
|
|
559
|
+
current_radius = max_radius * (1 - progress)
|
|
560
|
+
|
|
561
|
+
result = next_frame.copy()
|
|
562
|
+
|
|
563
|
+
# Create circular mask
|
|
564
|
+
y, x = np.ogrid[:h, :w]
|
|
565
|
+
mask = (x - center_x) ** 2 + (y - center_y) ** 2 <= current_radius**2
|
|
566
|
+
result[mask] = prev_frame[mask]
|
|
567
|
+
|
|
568
|
+
return result
|
|
569
|
+
|
|
570
|
+
# Fade variations
|
|
571
|
+
def _fade_to_black(
|
|
572
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
573
|
+
) -> np.ndarray:
|
|
574
|
+
if progress < 0.5:
|
|
575
|
+
# Fade to black
|
|
576
|
+
fade_progress = progress * 2
|
|
577
|
+
black_frame = np.zeros_like(prev_frame)
|
|
578
|
+
return self._crossfade(prev_frame, black_frame, fade_progress)
|
|
579
|
+
# Fade from black
|
|
580
|
+
fade_progress = (progress - 0.5) * 2
|
|
581
|
+
black_frame = np.zeros_like(next_frame)
|
|
582
|
+
return self._crossfade(black_frame, next_frame, fade_progress)
|
|
583
|
+
|
|
584
|
+
def _fade_to_white(
|
|
585
|
+
self, prev_frame: np.ndarray, next_frame: np.ndarray, progress: float
|
|
586
|
+
) -> np.ndarray:
|
|
587
|
+
if progress < 0.5:
|
|
588
|
+
# Fade to white
|
|
589
|
+
fade_progress = progress * 2
|
|
590
|
+
white_frame = np.full_like(prev_frame, 255)
|
|
591
|
+
return self._crossfade(prev_frame, white_frame, fade_progress)
|
|
592
|
+
# Fade from white
|
|
593
|
+
fade_progress = (progress - 0.5) * 2
|
|
594
|
+
white_frame = np.full_like(next_frame, 255)
|
|
595
|
+
return self._crossfade(white_frame, next_frame, fade_progress)
|
visualkit/utils.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: visualkit
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Lightning-fast Python package for video frame effects and transitions. Comprehensive collection of visual effects with optimized OpenCV backend for maximum rendering speed.
|
|
5
|
+
Author-email: Suraj Airi <surajairi.ml@gmail.com>
|
|
6
|
+
License: MIT license
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: AUTHORS.rst
|
|
11
|
+
Requires-Dist: opencv-python>=4.12.0.88
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# VisualKit
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
Lightning-fast Python package for video frame effects and transitions. Comprehensive collection of visual effects with optimized OpenCV backend for maximum rendering speed.
|
|
18
|
+
|
|
19
|
+
## Getting Started
|
|
20
|
+
|
|
21
|
+
### Prerequisites
|
|
22
|
+
- List your requirements here
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
```bash
|
|
26
|
+
# Add installation commands
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Usage
|
|
30
|
+
```bash
|
|
31
|
+
# Add usage examples
|
|
32
|
+
```bash
|
|
33
|
+
# Add usage examples
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Project Structure
|
|
37
|
+
```
|
|
38
|
+
├── src/
|
|
39
|
+
├── tests/
|
|
40
|
+
├── docs/
|
|
41
|
+
└── README.md
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For detailed architecture information, see [docs/architecture.md](docs/architecture.md).
|
|
45
|
+
|
|
46
|
+
## Contributing
|
|
47
|
+
1. Fork the repository
|
|
48
|
+
2. Create a feature branch
|
|
49
|
+
3. Make your changes
|
|
50
|
+
4. Submit a pull request
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
This project is licensed under the [LICENSE](LICENSE) file in the root directory.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
visualkit/__init__.py,sha256=9judW6Ah-pXJ1Nby5zDbmixKgM76QrZL8SDahxtpRGk,242
|
|
2
|
+
visualkit/__main__.py,sha256=FtyOBvKwbJIekmKGF_8JF9y8y3CwO9emR-sw4Rg0NCI,71
|
|
3
|
+
visualkit/config.py,sha256=4RCVvF4C3tslac_FnW8M5czwuLjyDDSf7I5_70JsTMs,942
|
|
4
|
+
visualkit/editor.py,sha256=6QV4REnQpOd4nevrBX6g9i1VpbfIvfKJ-4FRPgK3d3k,8241
|
|
5
|
+
visualkit/enums.py,sha256=_oWF8pMBcEsXK5dR2U75Jotxuc8THi1yhQCbJiOK9SU,127
|
|
6
|
+
visualkit/media_element.py,sha256=omSSMGi3-Qs73M5O5F2WVInHVNTAqHnEpxca95UPfak,51503
|
|
7
|
+
visualkit/project_creator.py,sha256=JEYe4U11w3q0k37ZH_Zg_ZR9M1jT9LOUjvcRnrLzVZA,5102
|
|
8
|
+
visualkit/text_element.py,sha256=2jSOZJCN9zuF2183BgaFLvAXX-iarEr7xMVCXMaB7l8,9875
|
|
9
|
+
visualkit/timeline.py,sha256=pHs-B-DHQIm4BwSS5nYsZZCVnbxi6rFqeCzVYKqydI4,1703
|
|
10
|
+
visualkit/transitions.py,sha256=WJB0FqJOAhJjmQ2RZh0dmb9CX0NKpQqwmm7TafpijtA,20816
|
|
11
|
+
visualkit/utils.py,sha256=oJHLDKKLwWtePuBcxrfVblhgRB1It5jc1RW5pSQwSHI,113
|
|
12
|
+
visualkit-0.0.1.dist-info/licenses/AUTHORS.rst,sha256=YrLwz-rjegwO4EtBVYDsSNmX9fVraH_qXWiWnCxSHgE,54
|
|
13
|
+
visualkit-0.0.1.dist-info/licenses/LICENSE,sha256=Tqm-weC3hV93NO1OLFcAlQVcj7I-nGhfVn3TwpRV6d8,1098
|
|
14
|
+
visualkit-0.0.1.dist-info/METADATA,sha256=pMtF1HuHUqPdhqWc5RkT_dbtd9RUKpoagOunTw-c5pU,1273
|
|
15
|
+
visualkit-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
visualkit-0.0.1.dist-info/top_level.txt,sha256=1iCIznVqSQLoZvRs1kOq1qCV0ZxVJA5Q9EsUL4ubRqw,10
|
|
17
|
+
visualkit-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Suraj Airi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
visualkit
|