Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,10 @@
|
|
| 1 |
"""
|
| 2 |
Simple Video Editor - ํ๊น
ํ์ด์ค ์คํ์ด์ค์ฉ
|
| 3 |
-
CapCut/VEED ์คํ์ผ ๊ฐ๋จ ์์ ํธ์ง๊ธฐ
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
-
import os
|
| 8 |
-
import tempfile
|
| 9 |
-
import shutil
|
| 10 |
-
import subprocess
|
| 11 |
-
from pathlib import Path
|
| 12 |
|
| 13 |
-
# HTML/CSS/JS ์๋ฒ ๋ฉ
|
| 14 |
EDITOR_HTML = """
|
| 15 |
<!DOCTYPE html>
|
| 16 |
<html lang="ko">
|
|
@@ -19,239 +13,188 @@ EDITOR_HTML = """
|
|
| 19 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 20 |
<title>Simple Video Editor</title>
|
| 21 |
<style>
|
| 22 |
-
* {
|
| 23 |
-
margin: 0;
|
| 24 |
-
padding: 0;
|
| 25 |
-
box-sizing: border-box;
|
| 26 |
-
}
|
| 27 |
|
| 28 |
body {
|
| 29 |
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 30 |
-
background: #
|
| 31 |
-
color: #
|
| 32 |
overflow: hidden;
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
.editor-container {
|
| 36 |
display: flex;
|
| 37 |
flex-direction: column;
|
| 38 |
height: 100vh;
|
| 39 |
-
max-height:
|
| 40 |
}
|
| 41 |
|
| 42 |
-
/* ์๋จ ํด๋ฐ */
|
| 43 |
.toolbar {
|
| 44 |
-
height:
|
| 45 |
-
background:
|
| 46 |
-
border-bottom: 1px solid #
|
| 47 |
display: flex;
|
| 48 |
align-items: center;
|
| 49 |
justify-content: space-between;
|
| 50 |
-
padding: 0
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
.toolbar-title {
|
| 54 |
-
font-size:
|
| 55 |
-
font-weight:
|
| 56 |
-
|
| 57 |
-
-webkit-background-clip: text;
|
| 58 |
-
-webkit-text-fill-color: transparent;
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
.toolbar-actions {
|
| 62 |
display: flex;
|
| 63 |
-
|
|
|
|
| 64 |
}
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
.btn {
|
| 67 |
-
padding:
|
| 68 |
border: none;
|
| 69 |
border-radius: 6px;
|
| 70 |
cursor: pointer;
|
| 71 |
-
font-size:
|
| 72 |
font-weight: 500;
|
| 73 |
display: flex;
|
| 74 |
align-items: center;
|
| 75 |
-
gap:
|
| 76 |
-
transition: all 0.
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
.btn-primary {
|
| 80 |
-
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 81 |
-
color: white;
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
.btn-primary:hover {
|
| 85 |
-
transform: translateY(-1px);
|
| 86 |
-
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
.btn-success {
|
| 90 |
-
background: linear-gradient(135deg, #11998e, #38ef7d);
|
| 91 |
-
color: white;
|
| 92 |
}
|
| 93 |
|
| 94 |
-
.btn
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
.btn-secondary {
|
| 100 |
-
background: #333;
|
| 101 |
-
color: #fff;
|
| 102 |
-
border: 1px solid #444;
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
.btn:disabled {
|
| 106 |
-
opacity: 0.5;
|
| 107 |
-
cursor: not-allowed;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
/* ๋ฉ์ธ ์์ญ */
|
| 111 |
.main-area {
|
| 112 |
display: flex;
|
| 113 |
flex: 1;
|
| 114 |
overflow: hidden;
|
|
|
|
| 115 |
}
|
| 116 |
|
| 117 |
-
/* ๋ฏธ๋์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ */
|
| 118 |
.media-library {
|
| 119 |
-
width:
|
| 120 |
-
background: #
|
| 121 |
-
border-right: 1px solid #
|
| 122 |
display: flex;
|
| 123 |
flex-direction: column;
|
| 124 |
}
|
| 125 |
|
| 126 |
.library-header {
|
| 127 |
-
padding: 12px;
|
| 128 |
-
border-bottom: 1px solid #
|
| 129 |
-
font-size:
|
| 130 |
font-weight: 600;
|
| 131 |
-
color: #
|
| 132 |
text-transform: uppercase;
|
| 133 |
}
|
| 134 |
|
| 135 |
.library-content {
|
| 136 |
flex: 1;
|
| 137 |
overflow-y: auto;
|
| 138 |
-
padding:
|
| 139 |
}
|
| 140 |
|
| 141 |
.upload-zone {
|
| 142 |
-
border: 2px dashed #
|
| 143 |
border-radius: 8px;
|
| 144 |
-
padding:
|
| 145 |
text-align: center;
|
| 146 |
cursor: pointer;
|
| 147 |
-
transition: all 0.
|
| 148 |
-
margin-bottom: 10px;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.upload-zone:hover {
|
| 152 |
-
border-color: #667eea;
|
| 153 |
-
background: rgba(102, 126, 234, 0.1);
|
| 154 |
-
}
|
| 155 |
-
|
| 156 |
-
.upload-zone svg {
|
| 157 |
-
width: 32px;
|
| 158 |
-
height: 32px;
|
| 159 |
-
color: #666;
|
| 160 |
margin-bottom: 8px;
|
|
|
|
| 161 |
}
|
| 162 |
|
| 163 |
-
.upload-zone
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
}
|
| 167 |
|
| 168 |
.media-grid {
|
| 169 |
display: grid;
|
| 170 |
grid-template-columns: repeat(2, 1fr);
|
| 171 |
-
gap:
|
| 172 |
}
|
| 173 |
|
| 174 |
.media-item {
|
| 175 |
aspect-ratio: 16/9;
|
| 176 |
-
background: #
|
| 177 |
border-radius: 6px;
|
| 178 |
overflow: hidden;
|
| 179 |
cursor: grab;
|
| 180 |
position: relative;
|
| 181 |
-
transition: all 0.
|
|
|
|
| 182 |
}
|
| 183 |
|
| 184 |
.media-item:hover {
|
| 185 |
transform: scale(1.02);
|
| 186 |
-
box-shadow: 0
|
|
|
|
| 187 |
}
|
| 188 |
|
| 189 |
-
.media-item.
|
| 190 |
-
opacity: 0.5;
|
| 191 |
-
}
|
| 192 |
-
|
| 193 |
-
.media-item img, .media-item video {
|
| 194 |
-
width: 100%;
|
| 195 |
-
height: 100%;
|
| 196 |
-
object-fit: cover;
|
| 197 |
-
}
|
| 198 |
|
| 199 |
.media-item-overlay {
|
| 200 |
position: absolute;
|
| 201 |
inset: 0;
|
| 202 |
-
background: linear-gradient(transparent
|
| 203 |
opacity: 0;
|
| 204 |
-
transition: opacity 0.
|
| 205 |
display: flex;
|
| 206 |
align-items: flex-end;
|
| 207 |
-
padding:
|
| 208 |
-
}
|
| 209 |
-
|
| 210 |
-
.media-item:hover .media-item-overlay {
|
| 211 |
-
opacity: 1;
|
| 212 |
}
|
| 213 |
|
| 214 |
-
.media-item-
|
| 215 |
-
|
| 216 |
-
white-space: nowrap;
|
| 217 |
-
overflow: hidden;
|
| 218 |
-
text-overflow: ellipsis;
|
| 219 |
-
}
|
| 220 |
|
| 221 |
.media-item-duration {
|
| 222 |
position: absolute;
|
| 223 |
-
top:
|
| 224 |
-
right:
|
| 225 |
-
background: rgba(0,0,0,0.
|
| 226 |
-
padding:
|
| 227 |
border-radius: 3px;
|
| 228 |
-
font-size:
|
|
|
|
| 229 |
}
|
| 230 |
|
| 231 |
.media-item-type {
|
| 232 |
position: absolute;
|
| 233 |
-
top:
|
| 234 |
-
left:
|
| 235 |
-
width:
|
| 236 |
-
height:
|
| 237 |
-
background: rgba(0,0,0,0.
|
| 238 |
border-radius: 50%;
|
| 239 |
display: flex;
|
| 240 |
align-items: center;
|
| 241 |
justify-content: center;
|
| 242 |
}
|
| 243 |
|
| 244 |
-
.media-item-type svg {
|
| 245 |
-
width: 12px;
|
| 246 |
-
height: 12px;
|
| 247 |
-
}
|
| 248 |
|
| 249 |
-
/* ํ๋ฆฌ๋ทฐ ์์ญ */
|
| 250 |
.preview-area {
|
| 251 |
flex: 1;
|
| 252 |
display: flex;
|
| 253 |
flex-direction: column;
|
| 254 |
-
background: #
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
}
|
| 256 |
|
| 257 |
.preview-container {
|
|
@@ -261,245 +204,216 @@ EDITOR_HTML = """
|
|
| 261 |
justify-content: center;
|
| 262 |
position: relative;
|
| 263 |
overflow: hidden;
|
|
|
|
| 264 |
}
|
| 265 |
|
| 266 |
-
.preview-container video,
|
| 267 |
-
.preview-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
object-fit: contain;
|
| 271 |
-
}
|
| 272 |
-
|
| 273 |
-
.preview-placeholder {
|
| 274 |
-
text-align: center;
|
| 275 |
-
color: #444;
|
| 276 |
-
}
|
| 277 |
-
|
| 278 |
-
.preview-placeholder svg {
|
| 279 |
-
width: 64px;
|
| 280 |
-
height: 64px;
|
| 281 |
-
margin-bottom: 15px;
|
| 282 |
-
}
|
| 283 |
|
| 284 |
-
/* ์ฌ์ ์ปจํธ๋กค */
|
| 285 |
.playback-controls {
|
| 286 |
-
height:
|
| 287 |
-
background: #
|
| 288 |
-
border-top: 1px solid #333;
|
| 289 |
display: flex;
|
| 290 |
align-items: center;
|
| 291 |
justify-content: center;
|
| 292 |
-
gap:
|
| 293 |
-
padding: 0
|
| 294 |
}
|
| 295 |
|
| 296 |
.control-btn {
|
| 297 |
-
width:
|
| 298 |
-
height:
|
| 299 |
border: none;
|
| 300 |
border-radius: 50%;
|
| 301 |
-
background:
|
| 302 |
color: #fff;
|
| 303 |
cursor: pointer;
|
| 304 |
display: flex;
|
| 305 |
align-items: center;
|
| 306 |
justify-content: center;
|
| 307 |
-
transition: all 0.
|
| 308 |
}
|
| 309 |
|
| 310 |
-
.control-btn:hover {
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
}
|
| 313 |
|
| 314 |
-
.
|
| 315 |
-
width:
|
| 316 |
-
|
| 317 |
-
|
|
|
|
|
|
|
| 318 |
}
|
| 319 |
|
| 320 |
-
.
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
}
|
| 323 |
|
| 324 |
-
.
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
}
|
| 331 |
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
.timeline-area {
|
| 334 |
-
height:
|
| 335 |
-
background: #
|
| 336 |
-
border-top: 1px solid #
|
| 337 |
display: flex;
|
| 338 |
flex-direction: column;
|
| 339 |
}
|
| 340 |
|
| 341 |
.timeline-toolbar {
|
| 342 |
-
height:
|
| 343 |
-
background: #
|
| 344 |
-
border-bottom: 1px solid #
|
| 345 |
display: flex;
|
| 346 |
align-items: center;
|
| 347 |
-
padding: 0
|
| 348 |
-
gap:
|
| 349 |
}
|
| 350 |
|
|
|
|
|
|
|
|
|
|
| 351 |
.timeline-zoom {
|
| 352 |
display: flex;
|
| 353 |
align-items: center;
|
| 354 |
-
gap:
|
| 355 |
margin-left: auto;
|
|
|
|
|
|
|
| 356 |
}
|
| 357 |
|
| 358 |
-
.timeline-zoom input {
|
| 359 |
-
|
| 360 |
-
}
|
| 361 |
|
| 362 |
.timeline-container {
|
| 363 |
flex: 1;
|
| 364 |
overflow-x: auto;
|
| 365 |
overflow-y: hidden;
|
| 366 |
position: relative;
|
|
|
|
| 367 |
}
|
| 368 |
|
| 369 |
.timeline-ruler {
|
| 370 |
-
height:
|
| 371 |
-
background: #
|
| 372 |
position: sticky;
|
| 373 |
top: 0;
|
| 374 |
z-index: 10;
|
| 375 |
-
border-bottom: 1px solid #
|
| 376 |
}
|
| 377 |
|
| 378 |
-
.timeline-tracks {
|
| 379 |
-
position: relative;
|
| 380 |
-
min-height: 140px;
|
| 381 |
-
}
|
| 382 |
|
| 383 |
.timeline-track {
|
| 384 |
-
height:
|
| 385 |
-
border-bottom: 1px solid #
|
| 386 |
position: relative;
|
| 387 |
display: flex;
|
| 388 |
align-items: center;
|
|
|
|
| 389 |
}
|
| 390 |
|
|
|
|
|
|
|
| 391 |
.track-label {
|
| 392 |
-
width:
|
| 393 |
-
padding: 0
|
| 394 |
-
font-size:
|
| 395 |
-
color: #
|
| 396 |
-
background: #
|
| 397 |
height: 100%;
|
| 398 |
display: flex;
|
| 399 |
align-items: center;
|
| 400 |
-
|
|
|
|
| 401 |
position: sticky;
|
| 402 |
left: 0;
|
| 403 |
z-index: 5;
|
| 404 |
}
|
| 405 |
|
| 406 |
-
.track-
|
| 407 |
-
|
| 408 |
-
height: 100%;
|
| 409 |
-
position: relative;
|
| 410 |
-
}
|
| 411 |
|
| 412 |
.timeline-clip {
|
| 413 |
position: absolute;
|
| 414 |
-
height:
|
| 415 |
top: 5px;
|
| 416 |
border-radius: 6px;
|
| 417 |
cursor: grab;
|
| 418 |
display: flex;
|
| 419 |
align-items: center;
|
| 420 |
overflow: hidden;
|
| 421 |
-
transition: box-shadow 0.
|
| 422 |
-
min-width:
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
.timeline-clip:hover {
|
| 426 |
-
box-shadow: 0 0 0 2px #667eea;
|
| 427 |
-
}
|
| 428 |
-
|
| 429 |
-
.timeline-clip.selected {
|
| 430 |
-
box-shadow: 0 0 0 2px #667eea, 0 4px 15px rgba(102, 126, 234, 0.3);
|
| 431 |
-
}
|
| 432 |
-
|
| 433 |
-
.timeline-clip.video {
|
| 434 |
-
background: linear-gradient(135deg, #4a5568, #2d3748);
|
| 435 |
-
}
|
| 436 |
-
|
| 437 |
-
.timeline-clip.image {
|
| 438 |
-
background: linear-gradient(135deg, #38a169, #276749);
|
| 439 |
-
}
|
| 440 |
-
|
| 441 |
-
.timeline-clip.audio {
|
| 442 |
-
background: linear-gradient(135deg, #805ad5, #553c9a);
|
| 443 |
-
}
|
| 444 |
-
|
| 445 |
-
.clip-thumbnail {
|
| 446 |
-
width: 50px;
|
| 447 |
-
height: 100%;
|
| 448 |
-
object-fit: cover;
|
| 449 |
-
flex-shrink: 0;
|
| 450 |
-
}
|
| 451 |
-
|
| 452 |
-
.clip-info {
|
| 453 |
-
padding: 0 8px;
|
| 454 |
-
flex: 1;
|
| 455 |
-
overflow: hidden;
|
| 456 |
}
|
| 457 |
|
| 458 |
-
.
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
text-overflow: ellipsis;
|
| 464 |
-
}
|
| 465 |
|
| 466 |
-
.clip-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
}
|
| 470 |
|
| 471 |
.clip-handles {
|
| 472 |
position: absolute;
|
| 473 |
top: 0;
|
| 474 |
bottom: 0;
|
| 475 |
-
width:
|
| 476 |
-
background: rgba(255,255,255,0.
|
| 477 |
cursor: ew-resize;
|
| 478 |
opacity: 0;
|
| 479 |
-
transition: opacity 0.
|
| 480 |
-
}
|
| 481 |
-
|
| 482 |
-
.timeline-clip:hover .clip-handles {
|
| 483 |
-
opacity: 1;
|
| 484 |
-
}
|
| 485 |
-
|
| 486 |
-
.clip-handle-left {
|
| 487 |
-
left: 0;
|
| 488 |
-
border-radius: 6px 0 0 6px;
|
| 489 |
}
|
| 490 |
|
| 491 |
-
.clip-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
}
|
| 495 |
|
| 496 |
-
/* ํ๋ ์ดํค๋ */
|
| 497 |
.playhead {
|
| 498 |
position: absolute;
|
| 499 |
top: 0;
|
| 500 |
bottom: 0;
|
| 501 |
width: 2px;
|
| 502 |
-
background: #
|
| 503 |
z-index: 20;
|
| 504 |
pointer-events: none;
|
| 505 |
}
|
|
@@ -508,108 +422,24 @@ EDITOR_HTML = """
|
|
| 508 |
content: '';
|
| 509 |
position: absolute;
|
| 510 |
top: 0;
|
| 511 |
-
left: -
|
| 512 |
-
width:
|
| 513 |
-
height:
|
| 514 |
-
background: #
|
| 515 |
clip-path: polygon(50% 100%, 0 0, 100% 0);
|
| 516 |
}
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
border-left: 1px solid #333;
|
| 523 |
-
display: flex;
|
| 524 |
-
flex-direction: column;
|
| 525 |
-
}
|
| 526 |
-
|
| 527 |
-
.properties-header {
|
| 528 |
-
padding: 12px;
|
| 529 |
-
border-bottom: 1px solid #333;
|
| 530 |
-
font-size: 13px;
|
| 531 |
-
font-weight: 600;
|
| 532 |
-
color: #888;
|
| 533 |
-
text-transform: uppercase;
|
| 534 |
-
}
|
| 535 |
-
|
| 536 |
-
.properties-content {
|
| 537 |
-
flex: 1;
|
| 538 |
-
padding: 15px;
|
| 539 |
-
overflow-y: auto;
|
| 540 |
-
}
|
| 541 |
-
|
| 542 |
-
.property-group {
|
| 543 |
-
margin-bottom: 20px;
|
| 544 |
-
}
|
| 545 |
-
|
| 546 |
-
.property-label {
|
| 547 |
-
font-size: 11px;
|
| 548 |
-
color: #666;
|
| 549 |
-
margin-bottom: 6px;
|
| 550 |
-
text-transform: uppercase;
|
| 551 |
-
}
|
| 552 |
-
|
| 553 |
-
.property-input {
|
| 554 |
-
width: 100%;
|
| 555 |
-
padding: 8px 10px;
|
| 556 |
-
background: #252540;
|
| 557 |
-
border: 1px solid #333;
|
| 558 |
-
border-radius: 6px;
|
| 559 |
-
color: #fff;
|
| 560 |
-
font-size: 13px;
|
| 561 |
-
}
|
| 562 |
-
|
| 563 |
-
.property-input:focus {
|
| 564 |
-
outline: none;
|
| 565 |
-
border-color: #667eea;
|
| 566 |
-
}
|
| 567 |
-
|
| 568 |
-
.property-row {
|
| 569 |
-
display: flex;
|
| 570 |
-
gap: 10px;
|
| 571 |
-
}
|
| 572 |
-
|
| 573 |
-
.property-row > div {
|
| 574 |
-
flex: 1;
|
| 575 |
-
}
|
| 576 |
-
|
| 577 |
-
.no-selection {
|
| 578 |
-
color: #444;
|
| 579 |
-
text-align: center;
|
| 580 |
-
padding: 40px 20px;
|
| 581 |
-
}
|
| 582 |
-
|
| 583 |
-
/* ์คํฌ๋กค๋ฐ ์คํ์ผ */
|
| 584 |
-
::-webkit-scrollbar {
|
| 585 |
-
width: 8px;
|
| 586 |
-
height: 8px;
|
| 587 |
-
}
|
| 588 |
-
|
| 589 |
-
::-webkit-scrollbar-track {
|
| 590 |
-
background: #1a1a2e;
|
| 591 |
-
}
|
| 592 |
-
|
| 593 |
-
::-webkit-scrollbar-thumb {
|
| 594 |
-
background: #333;
|
| 595 |
-
border-radius: 4px;
|
| 596 |
-
}
|
| 597 |
-
|
| 598 |
-
::-webkit-scrollbar-thumb:hover {
|
| 599 |
-
background: #444;
|
| 600 |
-
}
|
| 601 |
|
| 602 |
-
|
| 603 |
-
.drop-highlight {
|
| 604 |
-
background: rgba(102, 126, 234, 0.2) !important;
|
| 605 |
-
border: 2px dashed #667eea !important;
|
| 606 |
-
}
|
| 607 |
|
| 608 |
-
/* ๋ชจ๋ฌ */
|
| 609 |
.modal-overlay {
|
| 610 |
position: fixed;
|
| 611 |
inset: 0;
|
| 612 |
-
background: rgba(0,0,0,0.
|
| 613 |
display: flex;
|
| 614 |
align-items: center;
|
| 615 |
justify-content: center;
|
|
@@ -617,217 +447,154 @@ EDITOR_HTML = """
|
|
| 617 |
}
|
| 618 |
|
| 619 |
.modal {
|
| 620 |
-
background: #
|
| 621 |
border-radius: 12px;
|
| 622 |
-
padding:
|
| 623 |
-
min-width:
|
| 624 |
text-align: center;
|
|
|
|
| 625 |
}
|
| 626 |
|
| 627 |
-
.modal h3 {
|
| 628 |
-
|
| 629 |
-
}
|
| 630 |
-
|
| 631 |
-
.progress-bar {
|
| 632 |
-
height: 8px;
|
| 633 |
-
background: #333;
|
| 634 |
-
border-radius: 4px;
|
| 635 |
-
overflow: hidden;
|
| 636 |
-
margin: 20px 0;
|
| 637 |
-
}
|
| 638 |
-
|
| 639 |
-
.progress-fill {
|
| 640 |
-
height: 100%;
|
| 641 |
-
background: linear-gradient(90deg, #667eea, #764ba2);
|
| 642 |
-
transition: width 0.3s;
|
| 643 |
-
}
|
| 644 |
|
| 645 |
-
/* ์ปจํ
์คํธ ๋ฉ๋ด */
|
| 646 |
.context-menu {
|
| 647 |
position: fixed;
|
| 648 |
-
background: #
|
| 649 |
-
border: 1px solid #
|
| 650 |
border-radius: 8px;
|
| 651 |
-
padding:
|
| 652 |
-
min-width:
|
| 653 |
z-index: 1000;
|
| 654 |
-
box-shadow: 0 10px 40px rgba(0,0,0,0.
|
| 655 |
}
|
| 656 |
|
| 657 |
.context-menu-item {
|
| 658 |
-
padding:
|
| 659 |
cursor: pointer;
|
| 660 |
display: flex;
|
| 661 |
align-items: center;
|
| 662 |
-
gap:
|
| 663 |
-
font-size:
|
| 664 |
-
}
|
| 665 |
-
|
| 666 |
-
.context-menu-item:hover {
|
| 667 |
-
background: #333;
|
| 668 |
-
}
|
| 669 |
-
|
| 670 |
-
.context-menu-item.danger {
|
| 671 |
-
color: #ff4757;
|
| 672 |
}
|
| 673 |
|
| 674 |
-
.context-menu-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
}
|
| 679 |
</style>
|
| 680 |
</head>
|
| 681 |
<body>
|
| 682 |
<div class="editor-container">
|
| 683 |
-
<!-- ์๋จ ํด๋ฐ -->
|
| 684 |
<div class="toolbar">
|
| 685 |
-
<div class="toolbar-title">
|
|
|
|
|
|
|
|
|
|
| 686 |
<div class="toolbar-actions">
|
| 687 |
<button class="btn btn-secondary" onclick="undoAction()">
|
| 688 |
-
<svg
|
| 689 |
์คํ์ทจ์
|
| 690 |
</button>
|
| 691 |
-
<
|
| 692 |
-
<svg
|
| 693 |
ํ์ผ ์ถ๊ฐ
|
| 694 |
-
</
|
| 695 |
-
<
|
| 696 |
-
|
|
|
|
| 697 |
๋ด๋ณด๋ด๊ธฐ
|
| 698 |
</button>
|
| 699 |
</div>
|
| 700 |
-
<input type="file" id="fileInput" multiple accept="video/*,image/*,audio/*" style="display:none" onchange="handleFileUpload(event)">
|
| 701 |
</div>
|
| 702 |
|
| 703 |
-
<!-- ๋ฉ์ธ ์์ญ -->
|
| 704 |
<div class="main-area">
|
| 705 |
-
<!-- ๋ฏธ๋์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ -->
|
| 706 |
<div class="media-library">
|
| 707 |
-
<div class="library-header">๐ ๋ฏธ๋์ด
|
| 708 |
<div class="library-content">
|
| 709 |
-
<
|
| 710 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"/></svg>
|
| 711 |
-
<p>ํด๋ฆญ
|
| 712 |
-
</
|
| 713 |
<div class="media-grid" id="mediaGrid"></div>
|
| 714 |
</div>
|
| 715 |
</div>
|
| 716 |
|
| 717 |
-
<!-- ํ๋ฆฌ๋ทฐ + ์ปจํธ๋กค -->
|
| 718 |
<div class="preview-area">
|
| 719 |
<div class="preview-container" id="previewContainer">
|
| 720 |
<div class="preview-placeholder">
|
| 721 |
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><rect x="2" y="2" width="20" height="20" rx="2
|
| 722 |
-
<p>
|
| 723 |
</div>
|
| 724 |
</div>
|
| 725 |
|
| 726 |
<div class="playback-controls">
|
| 727 |
-
<button class="control-btn" onclick="skipToStart()">
|
| 728 |
-
|
| 729 |
-
</button>
|
| 730 |
-
<button class="control-btn" onclick="
|
| 731 |
-
|
| 732 |
-
</
|
| 733 |
-
<button class="control-btn
|
| 734 |
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" id="playIcon"><polygon points="5 3 19 12 5 21 5 3"/></svg>
|
| 735 |
-
</button>
|
| 736 |
-
<button class="control-btn" onclick="skipForward()">
|
| 737 |
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/></svg>
|
| 738 |
-
</button>
|
| 739 |
-
<button class="control-btn" onclick="skipToEnd()">
|
| 740 |
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/></svg>
|
| 741 |
-
</button>
|
| 742 |
-
<div class="time-display">
|
| 743 |
-
<span id="currentTimeDisplay">00:00.00</span> / <span id="durationDisplay">00:00.00</span>
|
| 744 |
-
</div>
|
| 745 |
-
<button class="control-btn" onclick="toggleMute()" id="muteBtn">
|
| 746 |
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" id="volumeIcon"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>
|
| 747 |
-
</button>
|
| 748 |
</div>
|
| 749 |
</div>
|
| 750 |
|
| 751 |
-
<!-- ์์ฑ ํจ๋ -->
|
| 752 |
<div class="properties-panel">
|
| 753 |
-
<div class="properties-header">โ๏ธ
|
| 754 |
<div class="properties-content" id="propertiesContent">
|
| 755 |
-
<div class="no-selection">
|
| 756 |
-
<p>ํด๋ฆฝ์ ์ ํํ๋ฉด<br>์์ฑ์ ํธ์งํ ์ ์์ต๋๋ค</p>
|
| 757 |
-
</div>
|
| 758 |
</div>
|
| 759 |
</div>
|
| 760 |
</div>
|
| 761 |
|
| 762 |
-
<!-- ํ์๋ผ์ธ -->
|
| 763 |
<div class="timeline-area">
|
| 764 |
<div class="timeline-toolbar">
|
| 765 |
-
<button class="btn btn-secondary
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
</button>
|
| 769 |
-
<button class="btn btn-secondary btn-sm" onclick="duplicateSelectedClip()">
|
| 770 |
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
|
| 771 |
-
๋ณต์
|
| 772 |
-
</button>
|
| 773 |
-
<button class="btn btn-danger btn-sm" onclick="deleteSelectedClip()">
|
| 774 |
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
| 775 |
-
์ญ์
|
| 776 |
-
</button>
|
| 777 |
<div class="timeline-zoom">
|
| 778 |
-
<svg
|
| 779 |
-
<input type="range" min="0.5" max="3" step="0.1" value="1"
|
| 780 |
-
<svg
|
| 781 |
</div>
|
| 782 |
</div>
|
| 783 |
<div class="timeline-container" id="timelineContainer">
|
| 784 |
<div class="timeline-ruler" id="timelineRuler"></div>
|
| 785 |
<div class="timeline-tracks" id="timelineTracks">
|
| 786 |
<div class="timeline-track" data-track="0">
|
| 787 |
-
<div class="track-label">
|
| 788 |
-
<div class="track-content" ondragover="handleDragOver(event)" ondrop="handleDrop(event, 0)"></div>
|
| 789 |
</div>
|
| 790 |
<div class="timeline-track" data-track="1">
|
| 791 |
-
<div class="track-label">
|
| 792 |
-
<div class="track-content" ondragover="handleDragOver(event)" ondrop="handleDrop(event, 1)"></div>
|
| 793 |
</div>
|
| 794 |
</div>
|
| 795 |
-
<div class="playhead" id="playhead" style="left:
|
| 796 |
</div>
|
| 797 |
</div>
|
| 798 |
</div>
|
| 799 |
|
| 800 |
-
<!-- ์ปจํ
์คํธ ๋ฉ๋ด -->
|
| 801 |
<div class="context-menu" id="contextMenu" style="display:none;">
|
| 802 |
-
<div class="context-menu-item" onclick="splitSelectedClip()">
|
| 803 |
-
|
| 804 |
-
์๋ฅด๊ธฐ
|
| 805 |
-
</div>
|
| 806 |
-
<div class="context-menu-item" onclick="duplicateSelectedClip()">
|
| 807 |
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
|
| 808 |
-
๋ณต์
|
| 809 |
-
</div>
|
| 810 |
<div class="context-menu-divider"></div>
|
| 811 |
-
<div class="context-menu-item danger" onclick="deleteSelectedClip()">
|
| 812 |
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
|
| 813 |
-
์ญ์
|
| 814 |
-
</div>
|
| 815 |
</div>
|
| 816 |
|
| 817 |
-
<!-- ๋ด๋ณด๋ด๊ธฐ ๋ชจ๋ฌ -->
|
| 818 |
<div class="modal-overlay" id="exportModal" style="display:none;">
|
| 819 |
<div class="modal">
|
| 820 |
<h3>๐ฌ ์์ ๋ด๋ณด๋ด๊ธฐ</h3>
|
| 821 |
<p id="exportStatus">์์์ ์ฒ๋ฆฌํ๊ณ ์์ต๋๋ค...</p>
|
| 822 |
-
<div class="progress-bar">
|
| 823 |
-
<div class="progress-fill" id="exportProgress" style="width: 0%"></div>
|
| 824 |
-
</div>
|
| 825 |
<button class="btn btn-secondary" onclick="cancelExport()" id="cancelExportBtn">์ทจ์</button>
|
| 826 |
</div>
|
| 827 |
</div>
|
| 828 |
|
| 829 |
<script>
|
| 830 |
-
// ========== ์ํ ๊ด๋ฆฌ ==========
|
| 831 |
let mediaLibrary = [];
|
| 832 |
let timelineClips = [];
|
| 833 |
let selectedClipId = null;
|
|
@@ -836,14 +603,22 @@ EDITOR_HTML = """
|
|
| 836 |
let currentTime = 0;
|
| 837 |
let totalDuration = 0;
|
| 838 |
let zoom = 1;
|
| 839 |
-
let pixelsPerSecond =
|
| 840 |
let undoStack = [];
|
| 841 |
let animationId = null;
|
| 842 |
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 847 |
|
| 848 |
function formatTime(seconds) {
|
| 849 |
const mins = Math.floor(seconds / 60);
|
|
@@ -865,17 +640,28 @@ EDITOR_HTML = """
|
|
| 865 |
}
|
| 866 |
}
|
| 867 |
|
| 868 |
-
// ========== ํ์ผ ์
๋ก๋ ==========
|
| 869 |
function handleFileUpload(event) {
|
| 870 |
-
const files =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 871 |
|
| 872 |
files.forEach(file => {
|
| 873 |
-
const
|
| 874 |
-
|
| 875 |
-
: file.type.startsWith('image') ? 'image'
|
| 876 |
-
: file.type.startsWith('audio') ? 'audio' : 'unknown';
|
| 877 |
|
| 878 |
-
|
|
|
|
| 879 |
|
| 880 |
const media = {
|
| 881 |
id: generateId(),
|
|
@@ -887,86 +673,78 @@ EDITOR_HTML = """
|
|
| 887 |
thumbnail: type === 'image' ? url : null
|
| 888 |
};
|
| 889 |
|
|
|
|
|
|
|
|
|
|
| 890 |
if (type === 'video' || type === 'audio') {
|
| 891 |
const el = document.createElement(type);
|
| 892 |
el.src = url;
|
| 893 |
-
el.
|
|
|
|
|
|
|
| 894 |
media.duration = el.duration;
|
| 895 |
-
|
| 896 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 897 |
if (type === 'video') {
|
| 898 |
-
|
| 899 |
-
el.onseeked = () => {
|
| 900 |
const canvas = document.createElement('canvas');
|
| 901 |
canvas.width = 160;
|
| 902 |
canvas.height = 90;
|
| 903 |
canvas.getContext('2d').drawImage(el, 0, 0, 160, 90);
|
| 904 |
media.thumbnail = canvas.toDataURL();
|
| 905 |
-
|
| 906 |
-
}
|
| 907 |
}
|
| 908 |
};
|
| 909 |
}
|
| 910 |
-
|
| 911 |
-
mediaLibrary.push(media);
|
| 912 |
-
renderMediaLibrary();
|
| 913 |
});
|
| 914 |
-
|
| 915 |
-
event.target.value = '';
|
| 916 |
-
}
|
| 917 |
-
|
| 918 |
-
function updateMediaItem(id) {
|
| 919 |
-
renderMediaLibrary();
|
| 920 |
}
|
| 921 |
|
| 922 |
-
// ========== ๋ฏธ๋์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ ๋๋ง ==========
|
| 923 |
function renderMediaLibrary() {
|
| 924 |
const grid = document.getElementById('mediaGrid');
|
| 925 |
grid.innerHTML = '';
|
| 926 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 927 |
mediaLibrary.forEach(media => {
|
| 928 |
const item = document.createElement('div');
|
| 929 |
item.className = 'media-item';
|
| 930 |
item.draggable = true;
|
| 931 |
item.dataset.mediaId = media.id;
|
| 932 |
|
| 933 |
-
item.ondragstart =
|
| 934 |
-
|
| 935 |
-
item.classList.add('dragging');
|
| 936 |
-
};
|
| 937 |
-
item.ondragend = () => item.classList.remove('dragging');
|
| 938 |
item.ondblclick = () => addToTimeline(media);
|
| 939 |
|
| 940 |
-
|
| 941 |
-
|
| 942 |
-
|
| 943 |
-
audio: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>'
|
| 944 |
-
};
|
| 945 |
|
| 946 |
item.innerHTML = `
|
| 947 |
-
${
|
| 948 |
-
|
| 949 |
-
${typeIcons[media.type] || ''}
|
| 950 |
-
</div>`}
|
| 951 |
-
<div class="media-item-type">${typeIcons[media.type] || ''}</div>
|
| 952 |
${media.duration > 0 ? `<div class="media-item-duration">${formatTime(media.duration)}</div>` : ''}
|
| 953 |
-
<div class="media-item-overlay">
|
| 954 |
-
<span class="media-item-name">${media.name}</span>
|
| 955 |
-
</div>
|
| 956 |
`;
|
| 957 |
|
| 958 |
grid.appendChild(item);
|
| 959 |
});
|
| 960 |
}
|
| 961 |
|
| 962 |
-
// ========== ํ์๋ผ์ธ์ ์ถ๊ฐ ==========
|
| 963 |
function addToTimeline(media, startTime = null) {
|
| 964 |
saveState();
|
| 965 |
-
|
| 966 |
const track = media.type === 'audio' ? 1 : 0;
|
| 967 |
const start = startTime !== null ? startTime : getTrackEndTime(track);
|
| 968 |
|
| 969 |
-
|
| 970 |
id: generateId(),
|
| 971 |
mediaId: media.id,
|
| 972 |
name: media.name,
|
|
@@ -979,25 +757,20 @@ EDITOR_HTML = """
|
|
| 979 |
trimStart: 0,
|
| 980 |
trimEnd: media.duration,
|
| 981 |
volume: 1
|
| 982 |
-
};
|
| 983 |
|
| 984 |
-
|
| 985 |
renderTimeline();
|
| 986 |
updateDuration();
|
| 987 |
}
|
| 988 |
|
| 989 |
function getTrackEndTime(track) {
|
| 990 |
-
const
|
| 991 |
-
|
| 992 |
-
return Math.max(...trackClips.map(c => c.startTime + (c.trimEnd - c.trimStart)));
|
| 993 |
}
|
| 994 |
|
| 995 |
-
// ========== ํ์๋ผ์ธ ๋ ๋๋ง ==========
|
| 996 |
function renderTimeline() {
|
| 997 |
-
|
| 998 |
-
tracks.forEach(track => {
|
| 999 |
-
track.innerHTML = '';
|
| 1000 |
-
});
|
| 1001 |
|
| 1002 |
timelineClips.forEach(clip => {
|
| 1003 |
const trackEl = document.querySelector(`.timeline-track[data-track="${clip.track}"] .track-content`);
|
|
@@ -1007,34 +780,18 @@ EDITOR_HTML = """
|
|
| 1007 |
clipEl.className = `timeline-clip ${clip.type}${selectedClipId === clip.id ? ' selected' : ''}`;
|
| 1008 |
clipEl.dataset.clipId = clip.id;
|
| 1009 |
|
| 1010 |
-
const
|
| 1011 |
-
|
| 1012 |
-
|
| 1013 |
-
|
| 1014 |
-
clipEl.style.left = `${left}px`;
|
| 1015 |
-
clipEl.style.width = `${width}px`;
|
| 1016 |
|
| 1017 |
clipEl.draggable = true;
|
| 1018 |
-
clipEl.onclick =
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
};
|
| 1022 |
-
clipEl.oncontextmenu = (e) => {
|
| 1023 |
-
e.preventDefault();
|
| 1024 |
-
selectClip(clip.id);
|
| 1025 |
-
showContextMenu(e.clientX, e.clientY);
|
| 1026 |
-
};
|
| 1027 |
-
clipEl.ondragstart = (e) => {
|
| 1028 |
-
e.dataTransfer.setData('clipId', clip.id);
|
| 1029 |
-
e.dataTransfer.setData('offsetX', e.offsetX.toString());
|
| 1030 |
-
};
|
| 1031 |
|
| 1032 |
clipEl.innerHTML = `
|
| 1033 |
${clip.thumbnail ? `<img class="clip-thumbnail" src="${clip.thumbnail}">` : ''}
|
| 1034 |
-
<div class="clip-info">
|
| 1035 |
-
<div class="clip-name">${clip.name}</div>
|
| 1036 |
-
<div class="clip-duration">${formatTime(clipDuration)}</div>
|
| 1037 |
-
</div>
|
| 1038 |
<div class="clip-handles clip-handle-left" onmousedown="startTrim(event, '${clip.id}', 'left')"></div>
|
| 1039 |
<div class="clip-handles clip-handle-right" onmousedown="startTrim(event, '${clip.id}', 'right')"></div>
|
| 1040 |
`;
|
|
@@ -1047,35 +804,26 @@ EDITOR_HTML = """
|
|
| 1047 |
|
| 1048 |
function renderRuler() {
|
| 1049 |
const ruler = document.getElementById('timelineRuler');
|
| 1050 |
-
|
| 1051 |
-
ruler.style.width = `${width}px`;
|
| 1052 |
-
|
| 1053 |
-
let html = '<svg width="100%" height="25" style="position:absolute;left:80px">';
|
| 1054 |
-
const step = zoom < 1 ? 5 : zoom < 2 ? 2 : 1;
|
| 1055 |
|
|
|
|
|
|
|
| 1056 |
for (let i = 0; i <= Math.ceil(totalDuration) + 10; i += step) {
|
| 1057 |
const x = i * pixelsPerSecond * zoom;
|
| 1058 |
-
html += `<line x1="${x}" y1="
|
| 1059 |
-
html += `<text x="${x}" y="15" fill="#666" font-size="10" text-anchor="middle">${formatTime(i)}</text>`;
|
| 1060 |
}
|
| 1061 |
-
html +
|
| 1062 |
-
ruler.innerHTML = html;
|
| 1063 |
}
|
| 1064 |
|
| 1065 |
-
|
| 1066 |
-
function
|
| 1067 |
-
event.preventDefault();
|
| 1068 |
-
event.currentTarget.classList.add('drop-highlight');
|
| 1069 |
-
}
|
| 1070 |
|
| 1071 |
function handleDrop(event, track) {
|
| 1072 |
event.preventDefault();
|
| 1073 |
event.currentTarget.classList.remove('drop-highlight');
|
| 1074 |
|
| 1075 |
const rect = event.currentTarget.getBoundingClientRect();
|
| 1076 |
-
const
|
| 1077 |
-
const time = Math.max(0, x / (pixelsPerSecond * zoom));
|
| 1078 |
-
|
| 1079 |
const mediaId = event.dataTransfer.getData('mediaId');
|
| 1080 |
const clipId = event.dataTransfer.getData('clipId');
|
| 1081 |
const offsetX = parseFloat(event.dataTransfer.getData('offsetX') || 0);
|
|
@@ -1083,102 +831,67 @@ EDITOR_HTML = """
|
|
| 1083 |
if (mediaId) {
|
| 1084 |
const media = mediaLibrary.find(m => m.id === mediaId);
|
| 1085 |
if (media) {
|
|
|
|
| 1086 |
addToTimeline(media, time);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1087 |
}
|
| 1088 |
} else if (clipId) {
|
| 1089 |
saveState();
|
| 1090 |
-
const
|
| 1091 |
-
|
| 1092 |
-
|
| 1093 |
-
|
|
|
|
| 1094 |
renderTimeline();
|
| 1095 |
updateDuration();
|
| 1096 |
}
|
| 1097 |
}
|
| 1098 |
|
| 1099 |
-
|
| 1100 |
-
function selectClip(clipId) {
|
| 1101 |
-
selectedClipId = clipId;
|
| 1102 |
-
renderTimeline();
|
| 1103 |
-
renderProperties();
|
| 1104 |
-
}
|
| 1105 |
|
| 1106 |
function renderProperties() {
|
| 1107 |
const container = document.getElementById('propertiesContent');
|
| 1108 |
const clip = timelineClips.find(c => c.id === selectedClipId);
|
| 1109 |
|
| 1110 |
if (!clip) {
|
| 1111 |
-
container.innerHTML = '<div class="no-selection">
|
| 1112 |
return;
|
| 1113 |
}
|
| 1114 |
|
| 1115 |
-
const
|
| 1116 |
-
|
| 1117 |
container.innerHTML = `
|
| 1118 |
-
<div class="property-group">
|
| 1119 |
-
|
| 1120 |
-
|
| 1121 |
-
</div>
|
| 1122 |
-
<div class="property-group">
|
| 1123 |
-
<div class="property-label">์์ ์๊ฐ</div>
|
| 1124 |
-
<input type="number" class="property-input" value="${clip.startTime.toFixed(2)}" step="0.1" min="0" onchange="updateClipProperty('startTime', parseFloat(this.value))">
|
| 1125 |
-
</div>
|
| 1126 |
-
<div class="property-group">
|
| 1127 |
-
<div class="property-row">
|
| 1128 |
-
<div>
|
| 1129 |
-
<div class="property-label">ํธ๋ฆผ ์์</div>
|
| 1130 |
-
<input type="number" class="property-input" value="${clip.trimStart.toFixed(2)}" step="0.1" min="0" max="${clip.duration}" onchange="updateClipProperty('trimStart', parseFloat(this.value))">
|
| 1131 |
-
</div>
|
| 1132 |
-
<div>
|
| 1133 |
-
<div class="property-label">ํธ๋ฆผ ๋</div>
|
| 1134 |
-
<input type="number" class="property-input" value="${clip.trimEnd.toFixed(2)}" step="0.1" min="0" max="${clip.duration}" onchange="updateClipProperty('trimEnd', parseFloat(this.value))">
|
| 1135 |
-
</div>
|
| 1136 |
-
</div>
|
| 1137 |
-
</div>
|
| 1138 |
-
<div class="property-group">
|
| 1139 |
-
<div class="property-label">๊ธธ์ด: ${formatTime(clipDuration)}</div>
|
| 1140 |
-
</div>
|
| 1141 |
-
${clip.type !== 'image' ? `
|
| 1142 |
-
<div class="property-group">
|
| 1143 |
-
<div class="property-label">๋ณผ๋ฅจ</div>
|
| 1144 |
-
<input type="range" class="property-input" min="0" max="1" step="0.1" value="${clip.volume}" onchange="updateClipProperty('volume', parseFloat(this.value))">
|
| 1145 |
-
</div>
|
| 1146 |
-
` : ''}
|
| 1147 |
`;
|
| 1148 |
}
|
| 1149 |
|
| 1150 |
function updateClipProperty(prop, value) {
|
| 1151 |
saveState();
|
| 1152 |
-
timelineClips = timelineClips.map(c =>
|
| 1153 |
-
c.id === selectedClipId ? { ...c, [prop]: value } : c
|
| 1154 |
-
);
|
| 1155 |
renderTimeline();
|
| 1156 |
updateDuration();
|
| 1157 |
renderProperties();
|
| 1158 |
}
|
| 1159 |
|
| 1160 |
-
// ========== ํด๋ฆฝ ํธ์ง ==========
|
| 1161 |
function splitSelectedClip() {
|
| 1162 |
if (!selectedClipId) return;
|
| 1163 |
const clip = timelineClips.find(c => c.id === selectedClipId);
|
| 1164 |
if (!clip) return;
|
| 1165 |
|
| 1166 |
saveState();
|
| 1167 |
-
|
| 1168 |
-
const
|
| 1169 |
-
const
|
| 1170 |
-
|
| 1171 |
-
const clip1 = { ...clip, trimEnd: clip.trimStart + splitPoint };
|
| 1172 |
-
const clip2 = {
|
| 1173 |
-
...clip,
|
| 1174 |
-
id: generateId(),
|
| 1175 |
-
startTime: clip.startTime + splitPoint,
|
| 1176 |
-
trimStart: clip.trimStart + splitPoint
|
| 1177 |
-
};
|
| 1178 |
|
| 1179 |
timelineClips = timelineClips.map(c => c.id === clip.id ? clip1 : c);
|
| 1180 |
timelineClips.push(clip2);
|
| 1181 |
-
|
| 1182 |
renderTimeline();
|
| 1183 |
hideContextMenu();
|
| 1184 |
}
|
|
@@ -1189,15 +902,7 @@ EDITOR_HTML = """
|
|
| 1189 |
if (!clip) return;
|
| 1190 |
|
| 1191 |
saveState();
|
| 1192 |
-
|
| 1193 |
-
const clipDuration = clip.trimEnd - clip.trimStart;
|
| 1194 |
-
const newClip = {
|
| 1195 |
-
...clip,
|
| 1196 |
-
id: generateId(),
|
| 1197 |
-
startTime: clip.startTime + clipDuration
|
| 1198 |
-
};
|
| 1199 |
-
|
| 1200 |
-
timelineClips.push(newClip);
|
| 1201 |
renderTimeline();
|
| 1202 |
updateDuration();
|
| 1203 |
hideContextMenu();
|
|
@@ -1205,328 +910,162 @@ EDITOR_HTML = """
|
|
| 1205 |
|
| 1206 |
function deleteSelectedClip() {
|
| 1207 |
if (!selectedClipId) return;
|
| 1208 |
-
|
| 1209 |
saveState();
|
| 1210 |
timelineClips = timelineClips.filter(c => c.id !== selectedClipId);
|
| 1211 |
selectedClipId = null;
|
| 1212 |
-
|
| 1213 |
renderTimeline();
|
| 1214 |
renderProperties();
|
| 1215 |
updateDuration();
|
| 1216 |
hideContextMenu();
|
| 1217 |
}
|
| 1218 |
|
| 1219 |
-
// ========== ํธ๋ฆผ ํธ๋ค ==========
|
| 1220 |
let trimData = null;
|
| 1221 |
-
|
| 1222 |
function startTrim(event, clipId, side) {
|
| 1223 |
event.stopPropagation();
|
| 1224 |
event.preventDefault();
|
| 1225 |
-
|
| 1226 |
const clip = timelineClips.find(c => c.id === clipId);
|
| 1227 |
if (!clip) return;
|
| 1228 |
-
|
| 1229 |
-
trimData = {
|
| 1230 |
-
clipId,
|
| 1231 |
-
side,
|
| 1232 |
-
startX: event.clientX,
|
| 1233 |
-
originalTrimStart: clip.trimStart,
|
| 1234 |
-
originalTrimEnd: clip.trimEnd,
|
| 1235 |
-
originalStartTime: clip.startTime
|
| 1236 |
-
};
|
| 1237 |
-
|
| 1238 |
document.addEventListener('mousemove', handleTrim);
|
| 1239 |
document.addEventListener('mouseup', endTrim);
|
| 1240 |
}
|
| 1241 |
|
| 1242 |
function handleTrim(event) {
|
| 1243 |
if (!trimData) return;
|
| 1244 |
-
|
| 1245 |
const clip = timelineClips.find(c => c.id === trimData.clipId);
|
| 1246 |
if (!clip) return;
|
| 1247 |
|
| 1248 |
-
const
|
| 1249 |
-
const deltaTime = deltaX / (pixelsPerSecond * zoom);
|
| 1250 |
-
|
| 1251 |
if (trimData.side === 'left') {
|
| 1252 |
const newTrimStart = Math.max(0, Math.min(clip.trimEnd - 0.1, trimData.originalTrimStart + deltaTime));
|
| 1253 |
-
const trimDelta = newTrimStart - trimData.originalTrimStart;
|
| 1254 |
clip.trimStart = newTrimStart;
|
| 1255 |
-
clip.startTime = trimData.originalStartTime +
|
| 1256 |
} else {
|
| 1257 |
clip.trimEnd = Math.max(clip.trimStart + 0.1, Math.min(clip.duration, trimData.originalTrimEnd + deltaTime));
|
| 1258 |
}
|
| 1259 |
-
|
| 1260 |
renderTimeline();
|
| 1261 |
updateDuration();
|
| 1262 |
}
|
| 1263 |
|
| 1264 |
function endTrim() {
|
| 1265 |
-
|
| 1266 |
-
saveState();
|
| 1267 |
-
trimData = null;
|
| 1268 |
-
}
|
| 1269 |
document.removeEventListener('mousemove', handleTrim);
|
| 1270 |
document.removeEventListener('mouseup', endTrim);
|
| 1271 |
}
|
| 1272 |
|
| 1273 |
-
// ========== ์ฌ์ ์ปจํธ๋กค ==========
|
| 1274 |
function updateDuration() {
|
| 1275 |
-
|
| 1276 |
-
totalDuration = 0;
|
| 1277 |
-
} else {
|
| 1278 |
-
totalDuration = Math.max(...timelineClips.map(c => c.startTime + (c.trimEnd - c.trimStart)));
|
| 1279 |
-
}
|
| 1280 |
document.getElementById('durationDisplay').textContent = formatTime(totalDuration);
|
| 1281 |
}
|
| 1282 |
|
| 1283 |
function togglePlay() {
|
| 1284 |
isPlaying = !isPlaying;
|
| 1285 |
const icon = document.getElementById('playIcon');
|
| 1286 |
-
|
| 1287 |
-
|
| 1288 |
-
icon.innerHTML = '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>';
|
| 1289 |
-
startPlayback();
|
| 1290 |
-
} else {
|
| 1291 |
-
icon.innerHTML = '<polygon points="5 3 19 12 5 21 5 3"/>';
|
| 1292 |
-
stopPlayback();
|
| 1293 |
-
}
|
| 1294 |
}
|
| 1295 |
|
| 1296 |
function startPlayback() {
|
| 1297 |
let lastTime = performance.now();
|
| 1298 |
-
|
| 1299 |
function animate(now) {
|
| 1300 |
if (!isPlaying) return;
|
| 1301 |
-
|
| 1302 |
-
const delta = (now - lastTime) / 1000;
|
| 1303 |
lastTime = now;
|
| 1304 |
-
|
| 1305 |
-
currentTime += delta;
|
| 1306 |
-
|
| 1307 |
-
if (currentTime >= totalDuration) {
|
| 1308 |
-
currentTime = 0;
|
| 1309 |
-
if (totalDuration === 0) {
|
| 1310 |
-
isPlaying = false;
|
| 1311 |
-
document.getElementById('playIcon').innerHTML = '<polygon points="5 3 19 12 5 21 5 3"/>';
|
| 1312 |
-
return;
|
| 1313 |
-
}
|
| 1314 |
-
}
|
| 1315 |
-
|
| 1316 |
updatePlayhead();
|
| 1317 |
updatePreview();
|
| 1318 |
-
|
| 1319 |
animationId = requestAnimationFrame(animate);
|
| 1320 |
}
|
| 1321 |
-
|
| 1322 |
animationId = requestAnimationFrame(animate);
|
| 1323 |
}
|
| 1324 |
|
| 1325 |
function stopPlayback() {
|
| 1326 |
-
if (animationId) {
|
| 1327 |
-
|
| 1328 |
-
|
| 1329 |
-
}
|
| 1330 |
}
|
| 1331 |
|
| 1332 |
function updatePlayhead() {
|
| 1333 |
-
|
| 1334 |
-
const left = 80 + (currentTime * pixelsPerSecond * zoom);
|
| 1335 |
-
playhead.style.left = `${left}px`;
|
| 1336 |
document.getElementById('currentTimeDisplay').textContent = formatTime(currentTime);
|
| 1337 |
}
|
| 1338 |
|
| 1339 |
function updatePreview() {
|
| 1340 |
const container = document.getElementById('previewContainer');
|
| 1341 |
-
const
|
| 1342 |
-
|
| 1343 |
-
return currentTime >= clip.startTime && currentTime < clipEnd;
|
| 1344 |
-
});
|
| 1345 |
|
| 1346 |
-
|
| 1347 |
-
|
| 1348 |
-
|
| 1349 |
-
|
| 1350 |
-
|
| 1351 |
-
|
| 1352 |
-
|
| 1353 |
-
if (
|
| 1354 |
-
|
| 1355 |
-
|
| 1356 |
-
|
| 1357 |
-
|
| 1358 |
-
if (!video) {
|
| 1359 |
-
container.innerHTML = `<video src="${visualClip.url}" data-clip-id="${visualClip.id}" style="max-width:100%;max-height:100%;" ${isMuted ? 'muted' : ''}></video>`;
|
| 1360 |
-
video = container.querySelector('video');
|
| 1361 |
-
}
|
| 1362 |
-
|
| 1363 |
-
if (Math.abs(video.currentTime - clipTime) > 0.1) {
|
| 1364 |
-
video.currentTime = clipTime;
|
| 1365 |
-
}
|
| 1366 |
-
|
| 1367 |
-
if (isPlaying && video.paused) {
|
| 1368 |
-
video.play().catch(() => {});
|
| 1369 |
-
} else if (!isPlaying && !video.paused) {
|
| 1370 |
-
video.pause();
|
| 1371 |
-
}
|
| 1372 |
-
|
| 1373 |
-
video.volume = isMuted ? 0 : visualClip.volume;
|
| 1374 |
}
|
| 1375 |
-
} else if (
|
| 1376 |
-
container.innerHTML = `
|
| 1377 |
-
<div class="preview-placeholder">
|
| 1378 |
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><rect x="2" y="2" width="20" height="20" rx="2.18" ry="2.18"/><line x1="7" y1="2" x2="7" y2="22"/><line x1="17" y1="2" x2="17" y2="22"/><line x1="2" y1="12" x2="22" y2="12"/></svg>
|
| 1379 |
-
<p>๋ฏธ๋์ด๋ฅผ ํ์๋ผ์ธ์ ์ถ๊ฐํ์ธ์</p>
|
| 1380 |
-
</div>
|
| 1381 |
-
`;
|
| 1382 |
}
|
| 1383 |
}
|
| 1384 |
|
| 1385 |
-
function skipToStart() {
|
| 1386 |
-
|
| 1387 |
-
|
| 1388 |
-
|
| 1389 |
-
}
|
| 1390 |
-
|
| 1391 |
-
function skipToEnd() {
|
| 1392 |
-
currentTime = totalDuration;
|
| 1393 |
-
updatePlayhead();
|
| 1394 |
-
updatePreview();
|
| 1395 |
-
}
|
| 1396 |
-
|
| 1397 |
-
function skipBackward() {
|
| 1398 |
-
currentTime = Math.max(0, currentTime - 5);
|
| 1399 |
-
updatePlayhead();
|
| 1400 |
-
updatePreview();
|
| 1401 |
-
}
|
| 1402 |
-
|
| 1403 |
-
function skipForward() {
|
| 1404 |
-
currentTime = Math.min(totalDuration, currentTime + 5);
|
| 1405 |
-
updatePlayhead();
|
| 1406 |
-
updatePreview();
|
| 1407 |
-
}
|
| 1408 |
|
| 1409 |
function toggleMute() {
|
| 1410 |
isMuted = !isMuted;
|
| 1411 |
-
|
| 1412 |
-
|
| 1413 |
-
if (isMuted) {
|
| 1414 |
-
icon.innerHTML = '<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/>';
|
| 1415 |
-
} else {
|
| 1416 |
-
icon.innerHTML = '<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/>';
|
| 1417 |
-
}
|
| 1418 |
-
|
| 1419 |
const video = document.querySelector('#previewContainer video');
|
| 1420 |
if (video) video.muted = isMuted;
|
| 1421 |
}
|
| 1422 |
|
| 1423 |
-
function setZoom(value) {
|
| 1424 |
-
zoom = parseFloat(value);
|
| 1425 |
-
renderTimeline();
|
| 1426 |
-
}
|
| 1427 |
|
| 1428 |
-
|
| 1429 |
-
function
|
| 1430 |
-
|
| 1431 |
-
menu.style.display = 'block';
|
| 1432 |
-
menu.style.left = `${x}px`;
|
| 1433 |
-
menu.style.top = `${y}px`;
|
| 1434 |
-
}
|
| 1435 |
|
| 1436 |
-
|
| 1437 |
-
|
| 1438 |
-
|
| 1439 |
-
|
| 1440 |
-
|
| 1441 |
-
if (!e.target.closest('.context-menu')) {
|
| 1442 |
-
hideContextMenu();
|
| 1443 |
-
}
|
| 1444 |
});
|
| 1445 |
|
| 1446 |
-
// ========== ๋ด๋ณด๋ด๊ธฐ ==========
|
| 1447 |
async function exportVideo() {
|
| 1448 |
-
if (timelineClips.length === 0) {
|
| 1449 |
-
alert('ํ์๋ผ์ธ์ ํด๋ฆฝ์ ์ถ๊ฐํด์ฃผ์ธ์.');
|
| 1450 |
-
return;
|
| 1451 |
-
}
|
| 1452 |
-
|
| 1453 |
document.getElementById('exportModal').style.display = 'flex';
|
| 1454 |
-
document.getElementById('exportProgress').style.width = '0%';
|
| 1455 |
-
document.getElementById('exportStatus').textContent = '์์์ ์ฒ๋ฆฌํ๊ณ ์์ต๋๋ค...';
|
| 1456 |
-
|
| 1457 |
-
// ์๋ฎฌ๋ ์ด์
(์ค์ ๋ก๋ ์๋ฒ๋ก ๋ฐ์ดํฐ ์ ์ก)
|
| 1458 |
for (let i = 0; i <= 100; i += 2) {
|
| 1459 |
await new Promise(r => setTimeout(r, 50));
|
| 1460 |
document.getElementById('exportProgress').style.width = `${i}%`;
|
| 1461 |
-
|
| 1462 |
if (i === 30) document.getElementById('exportStatus').textContent = 'ํด๋ฆฝ ๋ณํฉ ์ค...';
|
| 1463 |
if (i === 60) document.getElementById('exportStatus').textContent = '์ค๋์ค ์ฒ๋ฆฌ ์ค...';
|
| 1464 |
if (i === 90) document.getElementById('exportStatus').textContent = '์ต์ข
๋ ๋๋ง ์ค...';
|
| 1465 |
}
|
| 1466 |
-
|
| 1467 |
-
document.getElementById('exportStatus').textContent = '์๋ฃ!';
|
| 1468 |
document.getElementById('cancelExportBtn').textContent = '๋ซ๊ธฐ';
|
| 1469 |
-
|
| 1470 |
-
// ์ค์ ๊ตฌํ์ ์ฌ๊ธฐ์ ์๋ฒ๋ก ๋ฐ์ดํฐ ์ ์ก
|
| 1471 |
-
// ์๋ฒ์์ FFmpeg๋ก ์ฒ๋ฆฌ ํ ๋ค์ด๋ก๋ ๋งํฌ ์ ๊ณต
|
| 1472 |
}
|
| 1473 |
|
| 1474 |
-
function cancelExport() {
|
| 1475 |
-
document.getElementById('exportModal').style.display = 'none';
|
| 1476 |
-
document.getElementById('cancelExportBtn').textContent = '์ทจ์';
|
| 1477 |
-
}
|
| 1478 |
|
| 1479 |
-
|
| 1480 |
-
document.getElementById('timelineContainer').addEventListener('click', (e) => {
|
| 1481 |
-
if (e.target.closest('.timeline-clip')) return;
|
| 1482 |
-
|
| 1483 |
-
const rect = e.currentTarget.getBoundingClientRect();
|
| 1484 |
-
const x = e.clientX - rect.left - 80;
|
| 1485 |
-
currentTime = Math.max(0, Math.min(totalDuration, x / (pixelsPerSecond * zoom)));
|
| 1486 |
-
updatePlayhead();
|
| 1487 |
-
updatePreview();
|
| 1488 |
-
});
|
| 1489 |
-
|
| 1490 |
-
// ========== ํค๋ณด๋ ๋จ์ถํค ==========
|
| 1491 |
-
document.addEventListener('keydown', (e) => {
|
| 1492 |
if (e.target.tagName === 'INPUT') return;
|
| 1493 |
-
|
| 1494 |
switch(e.code) {
|
| 1495 |
-
case 'Space':
|
| 1496 |
-
|
| 1497 |
-
|
| 1498 |
-
|
| 1499 |
-
case '
|
| 1500 |
-
case '
|
| 1501 |
-
if (selectedClipId) deleteSelectedClip();
|
| 1502 |
-
break;
|
| 1503 |
-
case 'KeyD':
|
| 1504 |
-
if (e.ctrlKey || e.metaKey) {
|
| 1505 |
-
e.preventDefault();
|
| 1506 |
-
if (selectedClipId) duplicateSelectedClip();
|
| 1507 |
-
}
|
| 1508 |
-
break;
|
| 1509 |
-
case 'KeyZ':
|
| 1510 |
-
if (e.ctrlKey || e.metaKey) {
|
| 1511 |
-
e.preventDefault();
|
| 1512 |
-
undoAction();
|
| 1513 |
-
}
|
| 1514 |
-
break;
|
| 1515 |
-
case 'ArrowLeft':
|
| 1516 |
-
currentTime = Math.max(0, currentTime - (e.shiftKey ? 1 : 0.1));
|
| 1517 |
-
updatePlayhead();
|
| 1518 |
-
updatePreview();
|
| 1519 |
-
break;
|
| 1520 |
-
case 'ArrowRight':
|
| 1521 |
-
currentTime = Math.min(totalDuration, currentTime + (e.shiftKey ? 1 : 0.1));
|
| 1522 |
-
updatePlayhead();
|
| 1523 |
-
updatePreview();
|
| 1524 |
-
break;
|
| 1525 |
}
|
| 1526 |
});
|
| 1527 |
-
|
| 1528 |
-
// ========== ์ด๊ธฐํ ==========
|
| 1529 |
-
renderTimeline();
|
| 1530 |
</script>
|
| 1531 |
</body>
|
| 1532 |
</html>
|
|
@@ -1534,18 +1073,11 @@ EDITOR_HTML = """
|
|
| 1534 |
|
| 1535 |
|
| 1536 |
def create_interface():
|
| 1537 |
-
"""Gradio ์ธํฐํ์ด์ค ์์ฑ"""
|
| 1538 |
-
|
| 1539 |
with gr.Blocks(title="Simple Video Editor") as demo:
|
| 1540 |
gr.HTML(EDITOR_HTML)
|
| 1541 |
-
|
| 1542 |
return demo
|
| 1543 |
|
| 1544 |
|
| 1545 |
if __name__ == "__main__":
|
| 1546 |
demo = create_interface()
|
| 1547 |
-
demo.launch(
|
| 1548 |
-
server_name="0.0.0.0",
|
| 1549 |
-
server_port=7860,
|
| 1550 |
-
share=False
|
| 1551 |
-
)
|
|
|
|
| 1 |
"""
|
| 2 |
Simple Video Editor - ํ๊น
ํ์ด์ค ์คํ์ด์ค์ฉ
|
| 3 |
+
CapCut/VEED ์คํ์ผ ๊ฐ๋จ ์์ ํธ์ง๊ธฐ (ํฐ์ ํ
๋ง)
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
|
|
|
| 8 |
EDITOR_HTML = """
|
| 9 |
<!DOCTYPE html>
|
| 10 |
<html lang="ko">
|
|
|
|
| 13 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 14 |
<title>Simple Video Editor</title>
|
| 15 |
<style>
|
| 16 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
body {
|
| 19 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
|
| 20 |
+
background: #f5f5f7;
|
| 21 |
+
color: #1d1d1f;
|
| 22 |
overflow: hidden;
|
| 23 |
+
font-size: 13px;
|
| 24 |
}
|
| 25 |
|
| 26 |
.editor-container {
|
| 27 |
display: flex;
|
| 28 |
flex-direction: column;
|
| 29 |
height: 100vh;
|
| 30 |
+
max-height: 850px;
|
| 31 |
}
|
| 32 |
|
|
|
|
| 33 |
.toolbar {
|
| 34 |
+
height: 48px;
|
| 35 |
+
background: #ffffff;
|
| 36 |
+
border-bottom: 1px solid #e0e0e0;
|
| 37 |
display: flex;
|
| 38 |
align-items: center;
|
| 39 |
justify-content: space-between;
|
| 40 |
+
padding: 0 12px;
|
| 41 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
| 42 |
}
|
| 43 |
|
| 44 |
.toolbar-title {
|
| 45 |
+
font-size: 15px;
|
| 46 |
+
font-weight: 600;
|
| 47 |
+
color: #1d1d1f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
display: flex;
|
| 49 |
+
align-items: center;
|
| 50 |
+
gap: 6px;
|
| 51 |
}
|
| 52 |
|
| 53 |
+
.toolbar-title svg { width: 20px; height: 20px; color: #6366f1; }
|
| 54 |
+
.toolbar-actions { display: flex; gap: 8px; }
|
| 55 |
+
|
| 56 |
.btn {
|
| 57 |
+
padding: 6px 12px;
|
| 58 |
border: none;
|
| 59 |
border-radius: 6px;
|
| 60 |
cursor: pointer;
|
| 61 |
+
font-size: 12px;
|
| 62 |
font-weight: 500;
|
| 63 |
display: flex;
|
| 64 |
align-items: center;
|
| 65 |
+
gap: 4px;
|
| 66 |
+
transition: all 0.15s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
+
.btn svg { width: 14px; height: 14px; }
|
| 70 |
+
.btn-primary { background: #6366f1; color: white; }
|
| 71 |
+
.btn-primary:hover { background: #4f46e5; }
|
| 72 |
+
.btn-success { background: #10b981; color: white; }
|
| 73 |
+
.btn-success:hover { background: #059669; }
|
| 74 |
+
.btn-danger { background: #ef4444; color: white; }
|
| 75 |
+
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
|
| 76 |
+
.btn-secondary:hover { background: #e5e7eb; }
|
| 77 |
+
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
.main-area {
|
| 80 |
display: flex;
|
| 81 |
flex: 1;
|
| 82 |
overflow: hidden;
|
| 83 |
+
background: #f5f5f7;
|
| 84 |
}
|
| 85 |
|
|
|
|
| 86 |
.media-library {
|
| 87 |
+
width: 200px;
|
| 88 |
+
background: #ffffff;
|
| 89 |
+
border-right: 1px solid #e0e0e0;
|
| 90 |
display: flex;
|
| 91 |
flex-direction: column;
|
| 92 |
}
|
| 93 |
|
| 94 |
.library-header {
|
| 95 |
+
padding: 10px 12px;
|
| 96 |
+
border-bottom: 1px solid #e0e0e0;
|
| 97 |
+
font-size: 11px;
|
| 98 |
font-weight: 600;
|
| 99 |
+
color: #6b7280;
|
| 100 |
text-transform: uppercase;
|
| 101 |
}
|
| 102 |
|
| 103 |
.library-content {
|
| 104 |
flex: 1;
|
| 105 |
overflow-y: auto;
|
| 106 |
+
padding: 8px;
|
| 107 |
}
|
| 108 |
|
| 109 |
.upload-zone {
|
| 110 |
+
border: 2px dashed #d1d5db;
|
| 111 |
border-radius: 8px;
|
| 112 |
+
padding: 16px 8px;
|
| 113 |
text-align: center;
|
| 114 |
cursor: pointer;
|
| 115 |
+
transition: all 0.2s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
margin-bottom: 8px;
|
| 117 |
+
background: #fafafa;
|
| 118 |
}
|
| 119 |
|
| 120 |
+
.upload-zone:hover { border-color: #6366f1; background: #f0f0ff; }
|
| 121 |
+
.upload-zone svg { width: 24px; height: 24px; color: #9ca3af; margin-bottom: 6px; }
|
| 122 |
+
.upload-zone p { font-size: 11px; color: #6b7280; line-height: 1.4; }
|
|
|
|
| 123 |
|
| 124 |
.media-grid {
|
| 125 |
display: grid;
|
| 126 |
grid-template-columns: repeat(2, 1fr);
|
| 127 |
+
gap: 6px;
|
| 128 |
}
|
| 129 |
|
| 130 |
.media-item {
|
| 131 |
aspect-ratio: 16/9;
|
| 132 |
+
background: #f3f4f6;
|
| 133 |
border-radius: 6px;
|
| 134 |
overflow: hidden;
|
| 135 |
cursor: grab;
|
| 136 |
position: relative;
|
| 137 |
+
transition: all 0.15s;
|
| 138 |
+
border: 1px solid #e5e7eb;
|
| 139 |
}
|
| 140 |
|
| 141 |
.media-item:hover {
|
| 142 |
transform: scale(1.02);
|
| 143 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
| 144 |
+
border-color: #6366f1;
|
| 145 |
}
|
| 146 |
|
| 147 |
+
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
.media-item-overlay {
|
| 150 |
position: absolute;
|
| 151 |
inset: 0;
|
| 152 |
+
background: linear-gradient(transparent 40%, rgba(0,0,0,0.7));
|
| 153 |
opacity: 0;
|
| 154 |
+
transition: opacity 0.15s;
|
| 155 |
display: flex;
|
| 156 |
align-items: flex-end;
|
| 157 |
+
padding: 4px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
}
|
| 159 |
|
| 160 |
+
.media-item:hover .media-item-overlay { opacity: 1; }
|
| 161 |
+
.media-item-name { font-size: 9px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
.media-item-duration {
|
| 164 |
position: absolute;
|
| 165 |
+
top: 3px;
|
| 166 |
+
right: 3px;
|
| 167 |
+
background: rgba(0,0,0,0.6);
|
| 168 |
+
padding: 1px 4px;
|
| 169 |
border-radius: 3px;
|
| 170 |
+
font-size: 9px;
|
| 171 |
+
color: white;
|
| 172 |
}
|
| 173 |
|
| 174 |
.media-item-type {
|
| 175 |
position: absolute;
|
| 176 |
+
top: 3px;
|
| 177 |
+
left: 3px;
|
| 178 |
+
width: 16px;
|
| 179 |
+
height: 16px;
|
| 180 |
+
background: rgba(0,0,0,0.6);
|
| 181 |
border-radius: 50%;
|
| 182 |
display: flex;
|
| 183 |
align-items: center;
|
| 184 |
justify-content: center;
|
| 185 |
}
|
| 186 |
|
| 187 |
+
.media-item-type svg { width: 10px; height: 10px; color: white; }
|
|
|
|
|
|
|
|
|
|
| 188 |
|
|
|
|
| 189 |
.preview-area {
|
| 190 |
flex: 1;
|
| 191 |
display: flex;
|
| 192 |
flex-direction: column;
|
| 193 |
+
background: #1a1a1a;
|
| 194 |
+
margin: 8px;
|
| 195 |
+
border-radius: 12px;
|
| 196 |
+
overflow: hidden;
|
| 197 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
|
| 198 |
}
|
| 199 |
|
| 200 |
.preview-container {
|
|
|
|
| 204 |
justify-content: center;
|
| 205 |
position: relative;
|
| 206 |
overflow: hidden;
|
| 207 |
+
background: #000;
|
| 208 |
}
|
| 209 |
|
| 210 |
+
.preview-container video, .preview-container img { max-width: 100%; max-height: 100%; object-fit: contain; }
|
| 211 |
+
.preview-placeholder { text-align: center; color: #666; }
|
| 212 |
+
.preview-placeholder svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.5; }
|
| 213 |
+
.preview-placeholder p { font-size: 12px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
|
|
|
| 215 |
.playback-controls {
|
| 216 |
+
height: 50px;
|
| 217 |
+
background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
|
|
|
|
| 218 |
display: flex;
|
| 219 |
align-items: center;
|
| 220 |
justify-content: center;
|
| 221 |
+
gap: 8px;
|
| 222 |
+
padding: 0 16px;
|
| 223 |
}
|
| 224 |
|
| 225 |
.control-btn {
|
| 226 |
+
width: 32px;
|
| 227 |
+
height: 32px;
|
| 228 |
border: none;
|
| 229 |
border-radius: 50%;
|
| 230 |
+
background: rgba(255,255,255,0.1);
|
| 231 |
color: #fff;
|
| 232 |
cursor: pointer;
|
| 233 |
display: flex;
|
| 234 |
align-items: center;
|
| 235 |
justify-content: center;
|
| 236 |
+
transition: all 0.15s;
|
| 237 |
}
|
| 238 |
|
| 239 |
+
.control-btn:hover { background: rgba(255,255,255,0.2); }
|
| 240 |
+
.control-btn svg { width: 14px; height: 14px; }
|
| 241 |
+
.control-btn.play-btn { width: 40px; height: 40px; background: #6366f1; }
|
| 242 |
+
.control-btn.play-btn:hover { background: #4f46e5; transform: scale(1.05); }
|
| 243 |
+
.control-btn.play-btn svg { width: 18px; height: 18px; }
|
| 244 |
+
|
| 245 |
+
.time-display {
|
| 246 |
+
font-family: 'SF Mono', Monaco, monospace;
|
| 247 |
+
font-size: 11px;
|
| 248 |
+
color: #aaa;
|
| 249 |
+
min-width: 110px;
|
| 250 |
+
text-align: center;
|
| 251 |
}
|
| 252 |
|
| 253 |
+
.properties-panel {
|
| 254 |
+
width: 180px;
|
| 255 |
+
background: #ffffff;
|
| 256 |
+
border-left: 1px solid #e0e0e0;
|
| 257 |
+
display: flex;
|
| 258 |
+
flex-direction: column;
|
| 259 |
}
|
| 260 |
|
| 261 |
+
.properties-header {
|
| 262 |
+
padding: 10px 12px;
|
| 263 |
+
border-bottom: 1px solid #e0e0e0;
|
| 264 |
+
font-size: 11px;
|
| 265 |
+
font-weight: 600;
|
| 266 |
+
color: #6b7280;
|
| 267 |
+
text-transform: uppercase;
|
| 268 |
}
|
| 269 |
|
| 270 |
+
.properties-content { flex: 1; padding: 12px; overflow-y: auto; }
|
| 271 |
+
.property-group { margin-bottom: 14px; }
|
| 272 |
+
.property-label { font-size: 10px; color: #6b7280; margin-bottom: 4px; text-transform: uppercase; }
|
| 273 |
+
|
| 274 |
+
.property-input {
|
| 275 |
+
width: 100%;
|
| 276 |
+
padding: 6px 8px;
|
| 277 |
+
background: #f9fafb;
|
| 278 |
+
border: 1px solid #e5e7eb;
|
| 279 |
+
border-radius: 5px;
|
| 280 |
+
color: #1d1d1f;
|
| 281 |
+
font-size: 12px;
|
| 282 |
}
|
| 283 |
|
| 284 |
+
.property-input:focus { outline: none; border-color: #6366f1; }
|
| 285 |
+
.property-row { display: flex; gap: 8px; }
|
| 286 |
+
.property-row > div { flex: 1; }
|
| 287 |
+
.no-selection { color: #9ca3af; text-align: center; padding: 30px 15px; font-size: 12px; line-height: 1.5; }
|
| 288 |
+
|
| 289 |
.timeline-area {
|
| 290 |
+
height: 180px;
|
| 291 |
+
background: #ffffff;
|
| 292 |
+
border-top: 1px solid #e0e0e0;
|
| 293 |
display: flex;
|
| 294 |
flex-direction: column;
|
| 295 |
}
|
| 296 |
|
| 297 |
.timeline-toolbar {
|
| 298 |
+
height: 32px;
|
| 299 |
+
background: #fafafa;
|
| 300 |
+
border-bottom: 1px solid #e0e0e0;
|
| 301 |
display: flex;
|
| 302 |
align-items: center;
|
| 303 |
+
padding: 0 8px;
|
| 304 |
+
gap: 6px;
|
| 305 |
}
|
| 306 |
|
| 307 |
+
.timeline-toolbar .btn { padding: 4px 8px; font-size: 11px; }
|
| 308 |
+
.timeline-toolbar .btn svg { width: 12px; height: 12px; }
|
| 309 |
+
|
| 310 |
.timeline-zoom {
|
| 311 |
display: flex;
|
| 312 |
align-items: center;
|
| 313 |
+
gap: 4px;
|
| 314 |
margin-left: auto;
|
| 315 |
+
font-size: 11px;
|
| 316 |
+
color: #6b7280;
|
| 317 |
}
|
| 318 |
|
| 319 |
+
.timeline-zoom input { width: 60px; height: 4px; }
|
| 320 |
+
.timeline-zoom svg { width: 12px; height: 12px; }
|
|
|
|
| 321 |
|
| 322 |
.timeline-container {
|
| 323 |
flex: 1;
|
| 324 |
overflow-x: auto;
|
| 325 |
overflow-y: hidden;
|
| 326 |
position: relative;
|
| 327 |
+
background: #f9fafb;
|
| 328 |
}
|
| 329 |
|
| 330 |
.timeline-ruler {
|
| 331 |
+
height: 22px;
|
| 332 |
+
background: #fff;
|
| 333 |
position: sticky;
|
| 334 |
top: 0;
|
| 335 |
z-index: 10;
|
| 336 |
+
border-bottom: 1px solid #e5e7eb;
|
| 337 |
}
|
| 338 |
|
| 339 |
+
.timeline-tracks { position: relative; min-height: 120px; }
|
|
|
|
|
|
|
|
|
|
| 340 |
|
| 341 |
.timeline-track {
|
| 342 |
+
height: 55px;
|
| 343 |
+
border-bottom: 1px solid #e5e7eb;
|
| 344 |
position: relative;
|
| 345 |
display: flex;
|
| 346 |
align-items: center;
|
| 347 |
+
background: #fff;
|
| 348 |
}
|
| 349 |
|
| 350 |
+
.timeline-track:nth-child(2) { background: #fffbeb; }
|
| 351 |
+
|
| 352 |
.track-label {
|
| 353 |
+
width: 70px;
|
| 354 |
+
padding: 0 8px;
|
| 355 |
+
font-size: 10px;
|
| 356 |
+
color: #6b7280;
|
| 357 |
+
background: #f9fafb;
|
| 358 |
height: 100%;
|
| 359 |
display: flex;
|
| 360 |
align-items: center;
|
| 361 |
+
gap: 4px;
|
| 362 |
+
border-right: 1px solid #e5e7eb;
|
| 363 |
position: sticky;
|
| 364 |
left: 0;
|
| 365 |
z-index: 5;
|
| 366 |
}
|
| 367 |
|
| 368 |
+
.track-label svg { width: 12px; height: 12px; }
|
| 369 |
+
.track-content { flex: 1; height: 100%; position: relative; min-width: 800px; }
|
|
|
|
|
|
|
|
|
|
| 370 |
|
| 371 |
.timeline-clip {
|
| 372 |
position: absolute;
|
| 373 |
+
height: 45px;
|
| 374 |
top: 5px;
|
| 375 |
border-radius: 6px;
|
| 376 |
cursor: grab;
|
| 377 |
display: flex;
|
| 378 |
align-items: center;
|
| 379 |
overflow: hidden;
|
| 380 |
+
transition: box-shadow 0.15s;
|
| 381 |
+
min-width: 40px;
|
| 382 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
}
|
| 384 |
|
| 385 |
+
.timeline-clip:hover { box-shadow: 0 0 0 2px #6366f1; }
|
| 386 |
+
.timeline-clip.selected { box-shadow: 0 0 0 2px #6366f1, 0 4px 12px rgba(99, 102, 241, 0.3); }
|
| 387 |
+
.timeline-clip.video { background: linear-gradient(135deg, #818cf8, #6366f1); }
|
| 388 |
+
.timeline-clip.image { background: linear-gradient(135deg, #34d399, #10b981); }
|
| 389 |
+
.timeline-clip.audio { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
|
|
|
|
|
|
|
| 390 |
|
| 391 |
+
.clip-thumbnail { width: 45px; height: 100%; object-fit: cover; flex-shrink: 0; }
|
| 392 |
+
.clip-info { padding: 0 6px; flex: 1; overflow: hidden; }
|
| 393 |
+
.clip-name { font-size: 10px; font-weight: 500; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
| 394 |
+
.clip-duration { font-size: 9px; color: rgba(255,255,255,0.7); }
|
| 395 |
|
| 396 |
.clip-handles {
|
| 397 |
position: absolute;
|
| 398 |
top: 0;
|
| 399 |
bottom: 0;
|
| 400 |
+
width: 6px;
|
| 401 |
+
background: rgba(255,255,255,0.4);
|
| 402 |
cursor: ew-resize;
|
| 403 |
opacity: 0;
|
| 404 |
+
transition: opacity 0.15s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
}
|
| 406 |
|
| 407 |
+
.timeline-clip:hover .clip-handles { opacity: 1; }
|
| 408 |
+
.clip-handle-left { left: 0; border-radius: 6px 0 0 6px; }
|
| 409 |
+
.clip-handle-right { right: 0; border-radius: 0 6px 6px 0; }
|
|
|
|
| 410 |
|
|
|
|
| 411 |
.playhead {
|
| 412 |
position: absolute;
|
| 413 |
top: 0;
|
| 414 |
bottom: 0;
|
| 415 |
width: 2px;
|
| 416 |
+
background: #ef4444;
|
| 417 |
z-index: 20;
|
| 418 |
pointer-events: none;
|
| 419 |
}
|
|
|
|
| 422 |
content: '';
|
| 423 |
position: absolute;
|
| 424 |
top: 0;
|
| 425 |
+
left: -5px;
|
| 426 |
+
width: 12px;
|
| 427 |
+
height: 12px;
|
| 428 |
+
background: #ef4444;
|
| 429 |
clip-path: polygon(50% 100%, 0 0, 100% 0);
|
| 430 |
}
|
| 431 |
|
| 432 |
+
::-webkit-scrollbar { width: 6px; height: 6px; }
|
| 433 |
+
::-webkit-scrollbar-track { background: #f1f1f1; }
|
| 434 |
+
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
|
| 435 |
+
::-webkit-scrollbar-thumb:hover { background: #a1a1a1; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
|
| 437 |
+
.drop-highlight { background: rgba(99, 102, 241, 0.1) !important; outline: 2px dashed #6366f1 !important; outline-offset: -2px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
|
|
|
|
| 439 |
.modal-overlay {
|
| 440 |
position: fixed;
|
| 441 |
inset: 0;
|
| 442 |
+
background: rgba(0,0,0,0.5);
|
| 443 |
display: flex;
|
| 444 |
align-items: center;
|
| 445 |
justify-content: center;
|
|
|
|
| 447 |
}
|
| 448 |
|
| 449 |
.modal {
|
| 450 |
+
background: #fff;
|
| 451 |
border-radius: 12px;
|
| 452 |
+
padding: 24px;
|
| 453 |
+
min-width: 280px;
|
| 454 |
text-align: center;
|
| 455 |
+
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
| 456 |
}
|
| 457 |
|
| 458 |
+
.modal h3 { margin-bottom: 12px; font-size: 16px; }
|
| 459 |
+
.modal p { font-size: 13px; color: #6b7280; }
|
| 460 |
+
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin: 16px 0; }
|
| 461 |
+
.progress-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width 0.3s; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 462 |
|
|
|
|
| 463 |
.context-menu {
|
| 464 |
position: fixed;
|
| 465 |
+
background: #fff;
|
| 466 |
+
border: 1px solid #e5e7eb;
|
| 467 |
border-radius: 8px;
|
| 468 |
+
padding: 4px 0;
|
| 469 |
+
min-width: 140px;
|
| 470 |
z-index: 1000;
|
| 471 |
+
box-shadow: 0 10px 40px rgba(0,0,0,0.15);
|
| 472 |
}
|
| 473 |
|
| 474 |
.context-menu-item {
|
| 475 |
+
padding: 6px 12px;
|
| 476 |
cursor: pointer;
|
| 477 |
display: flex;
|
| 478 |
align-items: center;
|
| 479 |
+
gap: 8px;
|
| 480 |
+
font-size: 12px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 481 |
}
|
| 482 |
|
| 483 |
+
.context-menu-item:hover { background: #f3f4f6; }
|
| 484 |
+
.context-menu-item svg { width: 12px; height: 12px; }
|
| 485 |
+
.context-menu-item.danger { color: #ef4444; }
|
| 486 |
+
.context-menu-divider { height: 1px; background: #e5e7eb; margin: 4px 0; }
|
| 487 |
+
#fileInput { display: none; }
|
| 488 |
</style>
|
| 489 |
</head>
|
| 490 |
<body>
|
| 491 |
<div class="editor-container">
|
|
|
|
| 492 |
<div class="toolbar">
|
| 493 |
+
<div class="toolbar-title">
|
| 494 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="20" rx="2"/><line x1="7" y1="2" x2="7" y2="22"/><line x1="17" y1="2" x2="17" y2="22"/><line x1="2" y1="12" x2="22" y2="12"/></svg>
|
| 495 |
+
Simple Video Editor
|
| 496 |
+
</div>
|
| 497 |
<div class="toolbar-actions">
|
| 498 |
<button class="btn btn-secondary" onclick="undoAction()">
|
| 499 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 7v6h6M3 13a9 9 0 1 0 2.5-6.5"/></svg>
|
| 500 |
์คํ์ทจ์
|
| 501 |
</button>
|
| 502 |
+
<label class="btn btn-primary" for="fileInput">
|
| 503 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"/></svg>
|
| 504 |
ํ์ผ ์ถ๊ฐ
|
| 505 |
+
</label>
|
| 506 |
+
<input type="file" id="fileInput" multiple accept="video/*,image/*,audio/*">
|
| 507 |
+
<button class="btn btn-success" onclick="exportVideo()">
|
| 508 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"/></svg>
|
| 509 |
๋ด๋ณด๋ด๊ธฐ
|
| 510 |
</button>
|
| 511 |
</div>
|
|
|
|
| 512 |
</div>
|
| 513 |
|
|
|
|
| 514 |
<div class="main-area">
|
|
|
|
| 515 |
<div class="media-library">
|
| 516 |
+
<div class="library-header">๐ ๋ฏธ๋์ด</div>
|
| 517 |
<div class="library-content">
|
| 518 |
+
<label class="upload-zone" for="fileInput">
|
| 519 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"/></svg>
|
| 520 |
+
<p>ํด๋ฆญ ๋๋ ๋๋๊ทธ<br>์์/์ด๋ฏธ์ง/์ค๋์ค</p>
|
| 521 |
+
</label>
|
| 522 |
<div class="media-grid" id="mediaGrid"></div>
|
| 523 |
</div>
|
| 524 |
</div>
|
| 525 |
|
|
|
|
| 526 |
<div class="preview-area">
|
| 527 |
<div class="preview-container" id="previewContainer">
|
| 528 |
<div class="preview-placeholder">
|
| 529 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><rect x="2" y="2" width="20" height="20" rx="2"/><polygon points="10 8 16 12 10 16 10 8"/></svg>
|
| 530 |
+
<p>ํ์๋ผ์ธ์ ๋ฏธ๋์ด๋ฅผ ์ถ๊ฐํ์ธ์</p>
|
| 531 |
</div>
|
| 532 |
</div>
|
| 533 |
|
| 534 |
<div class="playback-controls">
|
| 535 |
+
<button class="control-btn" onclick="skipToStart()"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M6 6h2v12H6zm3.5 6l8.5 6V6z"/></svg></button>
|
| 536 |
+
<button class="control-btn" onclick="skipBackward()"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/></svg></button>
|
| 537 |
+
<button class="control-btn play-btn" onclick="togglePlay()" id="playBtn"><svg viewBox="0 0 24 24" fill="currentColor" id="playIcon"><polygon points="5 3 19 12 5 21 5 3"/></svg></button>
|
| 538 |
+
<button class="control-btn" onclick="skipForward()"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/></svg></button>
|
| 539 |
+
<button class="control-btn" onclick="skipToEnd()"><svg viewBox="0 0 24 24" fill="currentColor"><path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/></svg></button>
|
| 540 |
+
<div class="time-display"><span id="currentTimeDisplay">00:00.00</span> / <span id="durationDisplay">00:00.00</span></div>
|
| 541 |
+
<button class="control-btn" onclick="toggleMute()" id="muteBtn"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" id="volumeIcon"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/></svg></button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 542 |
</div>
|
| 543 |
</div>
|
| 544 |
|
|
|
|
| 545 |
<div class="properties-panel">
|
| 546 |
+
<div class="properties-header">โ๏ธ ์์ฑ</div>
|
| 547 |
<div class="properties-content" id="propertiesContent">
|
| 548 |
+
<div class="no-selection">ํด๋ฆฝ์ ์ ํํ๋ฉด<br>์์ฑ์ ํธ์งํ ์ ์์ต๋๋ค</div>
|
|
|
|
|
|
|
| 549 |
</div>
|
| 550 |
</div>
|
| 551 |
</div>
|
| 552 |
|
|
|
|
| 553 |
<div class="timeline-area">
|
| 554 |
<div class="timeline-toolbar">
|
| 555 |
+
<button class="btn btn-secondary" onclick="splitSelectedClip()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><line x1="20" y1="4" x2="8.12" y2="15.88"/><line x1="14.47" y1="14.48" x2="20" y2="20"/><line x1="8.12" y1="8.12" x2="12" y2="12"/></svg>์๋ฅด๊ธฐ</button>
|
| 556 |
+
<button class="btn btn-secondary" onclick="duplicateSelectedClip()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>๋ณต์ </button>
|
| 557 |
+
<button class="btn btn-danger" onclick="deleteSelectedClip()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>์ญ์ </button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 558 |
<div class="timeline-zoom">
|
| 559 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
|
| 560 |
+
<input type="range" min="0.5" max="3" step="0.1" value="1" oninput="setZoom(this.value)">
|
| 561 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
|
| 562 |
</div>
|
| 563 |
</div>
|
| 564 |
<div class="timeline-container" id="timelineContainer">
|
| 565 |
<div class="timeline-ruler" id="timelineRuler"></div>
|
| 566 |
<div class="timeline-tracks" id="timelineTracks">
|
| 567 |
<div class="timeline-track" data-track="0">
|
| 568 |
+
<div class="track-label"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>์์</div>
|
| 569 |
+
<div class="track-content" ondragover="handleDragOver(event)" ondrop="handleDrop(event, 0)" ondragleave="handleDragLeave(event)"></div>
|
| 570 |
</div>
|
| 571 |
<div class="timeline-track" data-track="1">
|
| 572 |
+
<div class="track-label"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>์ค๋์ค</div>
|
| 573 |
+
<div class="track-content" ondragover="handleDragOver(event)" ondrop="handleDrop(event, 1)" ondragleave="handleDragLeave(event)"></div>
|
| 574 |
</div>
|
| 575 |
</div>
|
| 576 |
+
<div class="playhead" id="playhead" style="left: 70px;"></div>
|
| 577 |
</div>
|
| 578 |
</div>
|
| 579 |
</div>
|
| 580 |
|
|
|
|
| 581 |
<div class="context-menu" id="contextMenu" style="display:none;">
|
| 582 |
+
<div class="context-menu-item" onclick="splitSelectedClip()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><line x1="20" y1="4" x2="8.12" y2="15.88"/></svg>์๋ฅด๊ธฐ</div>
|
| 583 |
+
<div class="context-menu-item" onclick="duplicateSelectedClip()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>๋ณต์ </div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
<div class="context-menu-divider"></div>
|
| 585 |
+
<div class="context-menu-item danger" onclick="deleteSelectedClip()"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/></svg>์ญ์ </div>
|
|
|
|
|
|
|
|
|
|
| 586 |
</div>
|
| 587 |
|
|
|
|
| 588 |
<div class="modal-overlay" id="exportModal" style="display:none;">
|
| 589 |
<div class="modal">
|
| 590 |
<h3>๐ฌ ์์ ๋ด๋ณด๋ด๊ธฐ</h3>
|
| 591 |
<p id="exportStatus">์์์ ์ฒ๋ฆฌํ๊ณ ์์ต๋๋ค...</p>
|
| 592 |
+
<div class="progress-bar"><div class="progress-fill" id="exportProgress" style="width: 0%"></div></div>
|
|
|
|
|
|
|
| 593 |
<button class="btn btn-secondary" onclick="cancelExport()" id="cancelExportBtn">์ทจ์</button>
|
| 594 |
</div>
|
| 595 |
</div>
|
| 596 |
|
| 597 |
<script>
|
|
|
|
| 598 |
let mediaLibrary = [];
|
| 599 |
let timelineClips = [];
|
| 600 |
let selectedClipId = null;
|
|
|
|
| 603 |
let currentTime = 0;
|
| 604 |
let totalDuration = 0;
|
| 605 |
let zoom = 1;
|
| 606 |
+
let pixelsPerSecond = 80;
|
| 607 |
let undoStack = [];
|
| 608 |
let animationId = null;
|
| 609 |
|
| 610 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 611 |
+
document.getElementById('fileInput').addEventListener('change', handleFileUpload);
|
| 612 |
+
document.addEventListener('dragover', e => e.preventDefault());
|
| 613 |
+
document.addEventListener('drop', function(e) {
|
| 614 |
+
e.preventDefault();
|
| 615 |
+
if (e.target.closest('.upload-zone') || e.target.closest('.library-content')) handleFileDrop(e);
|
| 616 |
+
});
|
| 617 |
+
renderTimeline();
|
| 618 |
+
console.log('์๋ํฐ ์ด๊ธฐํ ์๋ฃ');
|
| 619 |
+
});
|
| 620 |
+
|
| 621 |
+
function generateId() { return Date.now().toString(36) + Math.random().toString(36).substr(2); }
|
| 622 |
|
| 623 |
function formatTime(seconds) {
|
| 624 |
const mins = Math.floor(seconds / 60);
|
|
|
|
| 640 |
}
|
| 641 |
}
|
| 642 |
|
|
|
|
| 643 |
function handleFileUpload(event) {
|
| 644 |
+
const files = event.target.files;
|
| 645 |
+
if (!files || files.length === 0) return;
|
| 646 |
+
processFiles(Array.from(files));
|
| 647 |
+
event.target.value = '';
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
function handleFileDrop(event) {
|
| 651 |
+
const files = event.dataTransfer.files;
|
| 652 |
+
if (!files || files.length === 0) return;
|
| 653 |
+
processFiles(Array.from(files));
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
+
function processFiles(files) {
|
| 657 |
+
console.log('ํ์ผ ์ฒ๋ฆฌ:', files.length);
|
| 658 |
|
| 659 |
files.forEach(file => {
|
| 660 |
+
const type = file.type.startsWith('video') ? 'video' : file.type.startsWith('image') ? 'image' : file.type.startsWith('audio') ? 'audio' : null;
|
| 661 |
+
if (!type) return;
|
|
|
|
|
|
|
| 662 |
|
| 663 |
+
const url = URL.createObjectURL(file);
|
| 664 |
+
console.log('์ถ๊ฐ:', file.name, type);
|
| 665 |
|
| 666 |
const media = {
|
| 667 |
id: generateId(),
|
|
|
|
| 673 |
thumbnail: type === 'image' ? url : null
|
| 674 |
};
|
| 675 |
|
| 676 |
+
mediaLibrary.push(media);
|
| 677 |
+
renderMediaLibrary();
|
| 678 |
+
|
| 679 |
if (type === 'video' || type === 'audio') {
|
| 680 |
const el = document.createElement(type);
|
| 681 |
el.src = url;
|
| 682 |
+
el.preload = 'metadata';
|
| 683 |
+
|
| 684 |
+
el.onloadedmetadata = function() {
|
| 685 |
media.duration = el.duration;
|
| 686 |
+
console.log('๋ฉํ๋ฐ์ดํฐ:', file.name, el.duration);
|
| 687 |
+
renderMediaLibrary();
|
| 688 |
+
if (type === 'video') el.currentTime = Math.min(1, el.duration / 2);
|
| 689 |
+
};
|
| 690 |
+
|
| 691 |
+
el.onseeked = function() {
|
| 692 |
if (type === 'video') {
|
| 693 |
+
try {
|
|
|
|
| 694 |
const canvas = document.createElement('canvas');
|
| 695 |
canvas.width = 160;
|
| 696 |
canvas.height = 90;
|
| 697 |
canvas.getContext('2d').drawImage(el, 0, 0, 160, 90);
|
| 698 |
media.thumbnail = canvas.toDataURL();
|
| 699 |
+
renderMediaLibrary();
|
| 700 |
+
} catch(e) {}
|
| 701 |
}
|
| 702 |
};
|
| 703 |
}
|
|
|
|
|
|
|
|
|
|
| 704 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 705 |
}
|
| 706 |
|
|
|
|
| 707 |
function renderMediaLibrary() {
|
| 708 |
const grid = document.getElementById('mediaGrid');
|
| 709 |
grid.innerHTML = '';
|
| 710 |
|
| 711 |
+
const icons = {
|
| 712 |
+
video: '<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21"/></svg>',
|
| 713 |
+
image: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',
|
| 714 |
+
audio: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>'
|
| 715 |
+
};
|
| 716 |
+
|
| 717 |
mediaLibrary.forEach(media => {
|
| 718 |
const item = document.createElement('div');
|
| 719 |
item.className = 'media-item';
|
| 720 |
item.draggable = true;
|
| 721 |
item.dataset.mediaId = media.id;
|
| 722 |
|
| 723 |
+
item.ondragstart = e => { e.dataTransfer.setData('mediaId', media.id); item.style.opacity = '0.5'; };
|
| 724 |
+
item.ondragend = () => { item.style.opacity = '1'; };
|
|
|
|
|
|
|
|
|
|
| 725 |
item.ondblclick = () => addToTimeline(media);
|
| 726 |
|
| 727 |
+
let thumb = media.thumbnail
|
| 728 |
+
? `<img src="${media.thumbnail}" alt="${media.name}">`
|
| 729 |
+
: `<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:#e5e7eb;color:#9ca3af">${icons[media.type]}</div>`;
|
|
|
|
|
|
|
| 730 |
|
| 731 |
item.innerHTML = `
|
| 732 |
+
${thumb}
|
| 733 |
+
<div class="media-item-type">${icons[media.type]}</div>
|
|
|
|
|
|
|
|
|
|
| 734 |
${media.duration > 0 ? `<div class="media-item-duration">${formatTime(media.duration)}</div>` : ''}
|
| 735 |
+
<div class="media-item-overlay"><span class="media-item-name">${media.name}</span></div>
|
|
|
|
|
|
|
| 736 |
`;
|
| 737 |
|
| 738 |
grid.appendChild(item);
|
| 739 |
});
|
| 740 |
}
|
| 741 |
|
|
|
|
| 742 |
function addToTimeline(media, startTime = null) {
|
| 743 |
saveState();
|
|
|
|
| 744 |
const track = media.type === 'audio' ? 1 : 0;
|
| 745 |
const start = startTime !== null ? startTime : getTrackEndTime(track);
|
| 746 |
|
| 747 |
+
timelineClips.push({
|
| 748 |
id: generateId(),
|
| 749 |
mediaId: media.id,
|
| 750 |
name: media.name,
|
|
|
|
| 757 |
trimStart: 0,
|
| 758 |
trimEnd: media.duration,
|
| 759 |
volume: 1
|
| 760 |
+
});
|
| 761 |
|
| 762 |
+
console.log('ํด๋ฆฝ ์ถ๊ฐ:', media.name, 'track:', track);
|
| 763 |
renderTimeline();
|
| 764 |
updateDuration();
|
| 765 |
}
|
| 766 |
|
| 767 |
function getTrackEndTime(track) {
|
| 768 |
+
const clips = timelineClips.filter(c => c.track === track);
|
| 769 |
+
return clips.length === 0 ? 0 : Math.max(...clips.map(c => c.startTime + (c.trimEnd - c.trimStart)));
|
|
|
|
| 770 |
}
|
| 771 |
|
|
|
|
| 772 |
function renderTimeline() {
|
| 773 |
+
document.querySelectorAll('.track-content').forEach(t => t.innerHTML = '');
|
|
|
|
|
|
|
|
|
|
| 774 |
|
| 775 |
timelineClips.forEach(clip => {
|
| 776 |
const trackEl = document.querySelector(`.timeline-track[data-track="${clip.track}"] .track-content`);
|
|
|
|
| 780 |
clipEl.className = `timeline-clip ${clip.type}${selectedClipId === clip.id ? ' selected' : ''}`;
|
| 781 |
clipEl.dataset.clipId = clip.id;
|
| 782 |
|
| 783 |
+
const dur = clip.trimEnd - clip.trimStart;
|
| 784 |
+
clipEl.style.left = `${70 + clip.startTime * pixelsPerSecond * zoom}px`;
|
| 785 |
+
clipEl.style.width = `${Math.max(40, dur * pixelsPerSecond * zoom)}px`;
|
|
|
|
|
|
|
|
|
|
| 786 |
|
| 787 |
clipEl.draggable = true;
|
| 788 |
+
clipEl.onclick = e => { e.stopPropagation(); selectClip(clip.id); };
|
| 789 |
+
clipEl.oncontextmenu = e => { e.preventDefault(); selectClip(clip.id); showContextMenu(e.clientX, e.clientY); };
|
| 790 |
+
clipEl.ondragstart = e => { e.dataTransfer.setData('clipId', clip.id); e.dataTransfer.setData('offsetX', e.offsetX.toString()); };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 791 |
|
| 792 |
clipEl.innerHTML = `
|
| 793 |
${clip.thumbnail ? `<img class="clip-thumbnail" src="${clip.thumbnail}">` : ''}
|
| 794 |
+
<div class="clip-info"><div class="clip-name">${clip.name}</div><div class="clip-duration">${formatTime(dur)}</div></div>
|
|
|
|
|
|
|
|
|
|
| 795 |
<div class="clip-handles clip-handle-left" onmousedown="startTrim(event, '${clip.id}', 'left')"></div>
|
| 796 |
<div class="clip-handles clip-handle-right" onmousedown="startTrim(event, '${clip.id}', 'right')"></div>
|
| 797 |
`;
|
|
|
|
| 804 |
|
| 805 |
function renderRuler() {
|
| 806 |
const ruler = document.getElementById('timelineRuler');
|
| 807 |
+
ruler.style.width = `${Math.max(totalDuration * pixelsPerSecond * zoom + 300, 1000)}px`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 808 |
|
| 809 |
+
let html = '<svg width="100%" height="22" style="position:absolute;left:70px">';
|
| 810 |
+
const step = zoom < 0.7 ? 5 : zoom < 1.5 ? 2 : 1;
|
| 811 |
for (let i = 0; i <= Math.ceil(totalDuration) + 10; i += step) {
|
| 812 |
const x = i * pixelsPerSecond * zoom;
|
| 813 |
+
html += `<line x1="${x}" y1="17" x2="${x}" y2="22" stroke="#d1d5db"/><text x="${x}" y="12" fill="#9ca3af" font-size="9" text-anchor="middle">${formatTime(i)}</text>`;
|
|
|
|
| 814 |
}
|
| 815 |
+
ruler.innerHTML = html + '</svg>';
|
|
|
|
| 816 |
}
|
| 817 |
|
| 818 |
+
function handleDragOver(e) { e.preventDefault(); e.currentTarget.classList.add('drop-highlight'); }
|
| 819 |
+
function handleDragLeave(e) { e.currentTarget.classList.remove('drop-highlight'); }
|
|
|
|
|
|
|
|
|
|
| 820 |
|
| 821 |
function handleDrop(event, track) {
|
| 822 |
event.preventDefault();
|
| 823 |
event.currentTarget.classList.remove('drop-highlight');
|
| 824 |
|
| 825 |
const rect = event.currentTarget.getBoundingClientRect();
|
| 826 |
+
const time = Math.max(0, (event.clientX - rect.left) / (pixelsPerSecond * zoom));
|
|
|
|
|
|
|
| 827 |
const mediaId = event.dataTransfer.getData('mediaId');
|
| 828 |
const clipId = event.dataTransfer.getData('clipId');
|
| 829 |
const offsetX = parseFloat(event.dataTransfer.getData('offsetX') || 0);
|
|
|
|
| 831 |
if (mediaId) {
|
| 832 |
const media = mediaLibrary.find(m => m.id === mediaId);
|
| 833 |
if (media) {
|
| 834 |
+
const targetTrack = media.type === 'audio' ? 1 : track;
|
| 835 |
addToTimeline(media, time);
|
| 836 |
+
if (targetTrack !== track) {
|
| 837 |
+
timelineClips[timelineClips.length - 1].track = targetTrack;
|
| 838 |
+
renderTimeline();
|
| 839 |
+
}
|
| 840 |
}
|
| 841 |
} else if (clipId) {
|
| 842 |
saveState();
|
| 843 |
+
const clip = timelineClips.find(c => c.id === clipId);
|
| 844 |
+
if (clip) {
|
| 845 |
+
clip.startTime = Math.max(0, time - offsetX / (pixelsPerSecond * zoom));
|
| 846 |
+
clip.track = clip.type === 'audio' ? 1 : track;
|
| 847 |
+
}
|
| 848 |
renderTimeline();
|
| 849 |
updateDuration();
|
| 850 |
}
|
| 851 |
}
|
| 852 |
|
| 853 |
+
function selectClip(clipId) { selectedClipId = clipId; renderTimeline(); renderProperties(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 854 |
|
| 855 |
function renderProperties() {
|
| 856 |
const container = document.getElementById('propertiesContent');
|
| 857 |
const clip = timelineClips.find(c => c.id === selectedClipId);
|
| 858 |
|
| 859 |
if (!clip) {
|
| 860 |
+
container.innerHTML = '<div class="no-selection">ํด๋ฆฝ์ ์ ํํ๋ฉด<br>์์ฑ์ ํธ์งํ ์ ์์ต๋๋ค</div>';
|
| 861 |
return;
|
| 862 |
}
|
| 863 |
|
| 864 |
+
const dur = clip.trimEnd - clip.trimStart;
|
|
|
|
| 865 |
container.innerHTML = `
|
| 866 |
+
<div class="property-group"><div class="property-label">์ด๋ฆ</div><input type="text" class="property-input" value="${clip.name}" onchange="updateClipProperty('name', this.value)"></div>
|
| 867 |
+
<div class="property-group"><div class="property-label">์์ ์๊ฐ</div><input type="number" class="property-input" value="${clip.startTime.toFixed(2)}" step="0.1" min="0" onchange="updateClipProperty('startTime', parseFloat(this.value))"></div>
|
| 868 |
+
<div class="property-group"><div class="property-row"><div><div class="property-label">ํธ๋ฆผ ์์</div><input type="number" class="property-input" value="${clip.trimStart.toFixed(2)}" step="0.1" min="0" max="${clip.duration}" onchange="updateClipProperty('trimStart', parseFloat(this.value))"></div><div><div class="property-label">ํธ๋ฆผ ๋</div><input type="number" class="property-input" value="${clip.trimEnd.toFixed(2)}" step="0.1" min="0" max="${clip.duration}" onchange="updateClipProperty('trimEnd', parseFloat(this.value))"></div></div></div>
|
| 869 |
+
<div class="property-group"><div class="property-label">๊ธธ์ด</div><div style="padding:6px 0;font-size:12px;color:#374151">${formatTime(dur)}</div></div>
|
| 870 |
+
${clip.type !== 'image' ? `<div class="property-group"><div class="property-label">๋ณผ๋ฅจ (${Math.round(clip.volume * 100)}%)</div><input type="range" class="property-input" style="padding:0" min="0" max="1" step="0.05" value="${clip.volume}" oninput="updateClipProperty('volume', parseFloat(this.value))"></div>` : ''}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 871 |
`;
|
| 872 |
}
|
| 873 |
|
| 874 |
function updateClipProperty(prop, value) {
|
| 875 |
saveState();
|
| 876 |
+
timelineClips = timelineClips.map(c => c.id === selectedClipId ? { ...c, [prop]: value } : c);
|
|
|
|
|
|
|
| 877 |
renderTimeline();
|
| 878 |
updateDuration();
|
| 879 |
renderProperties();
|
| 880 |
}
|
| 881 |
|
|
|
|
| 882 |
function splitSelectedClip() {
|
| 883 |
if (!selectedClipId) return;
|
| 884 |
const clip = timelineClips.find(c => c.id === selectedClipId);
|
| 885 |
if (!clip) return;
|
| 886 |
|
| 887 |
saveState();
|
| 888 |
+
const dur = clip.trimEnd - clip.trimStart;
|
| 889 |
+
const split = dur / 2;
|
| 890 |
+
const clip1 = { ...clip, trimEnd: clip.trimStart + split };
|
| 891 |
+
const clip2 = { ...clip, id: generateId(), startTime: clip.startTime + split, trimStart: clip.trimStart + split };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 892 |
|
| 893 |
timelineClips = timelineClips.map(c => c.id === clip.id ? clip1 : c);
|
| 894 |
timelineClips.push(clip2);
|
|
|
|
| 895 |
renderTimeline();
|
| 896 |
hideContextMenu();
|
| 897 |
}
|
|
|
|
| 902 |
if (!clip) return;
|
| 903 |
|
| 904 |
saveState();
|
| 905 |
+
timelineClips.push({ ...clip, id: generateId(), startTime: clip.startTime + (clip.trimEnd - clip.trimStart) });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 906 |
renderTimeline();
|
| 907 |
updateDuration();
|
| 908 |
hideContextMenu();
|
|
|
|
| 910 |
|
| 911 |
function deleteSelectedClip() {
|
| 912 |
if (!selectedClipId) return;
|
|
|
|
| 913 |
saveState();
|
| 914 |
timelineClips = timelineClips.filter(c => c.id !== selectedClipId);
|
| 915 |
selectedClipId = null;
|
|
|
|
| 916 |
renderTimeline();
|
| 917 |
renderProperties();
|
| 918 |
updateDuration();
|
| 919 |
hideContextMenu();
|
| 920 |
}
|
| 921 |
|
|
|
|
| 922 |
let trimData = null;
|
|
|
|
| 923 |
function startTrim(event, clipId, side) {
|
| 924 |
event.stopPropagation();
|
| 925 |
event.preventDefault();
|
|
|
|
| 926 |
const clip = timelineClips.find(c => c.id === clipId);
|
| 927 |
if (!clip) return;
|
| 928 |
+
saveState();
|
| 929 |
+
trimData = { clipId, side, startX: event.clientX, originalTrimStart: clip.trimStart, originalTrimEnd: clip.trimEnd, originalStartTime: clip.startTime };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 930 |
document.addEventListener('mousemove', handleTrim);
|
| 931 |
document.addEventListener('mouseup', endTrim);
|
| 932 |
}
|
| 933 |
|
| 934 |
function handleTrim(event) {
|
| 935 |
if (!trimData) return;
|
|
|
|
| 936 |
const clip = timelineClips.find(c => c.id === trimData.clipId);
|
| 937 |
if (!clip) return;
|
| 938 |
|
| 939 |
+
const deltaTime = (event.clientX - trimData.startX) / (pixelsPerSecond * zoom);
|
|
|
|
|
|
|
| 940 |
if (trimData.side === 'left') {
|
| 941 |
const newTrimStart = Math.max(0, Math.min(clip.trimEnd - 0.1, trimData.originalTrimStart + deltaTime));
|
|
|
|
| 942 |
clip.trimStart = newTrimStart;
|
| 943 |
+
clip.startTime = trimData.originalStartTime + (newTrimStart - trimData.originalTrimStart);
|
| 944 |
} else {
|
| 945 |
clip.trimEnd = Math.max(clip.trimStart + 0.1, Math.min(clip.duration, trimData.originalTrimEnd + deltaTime));
|
| 946 |
}
|
|
|
|
| 947 |
renderTimeline();
|
| 948 |
updateDuration();
|
| 949 |
}
|
| 950 |
|
| 951 |
function endTrim() {
|
| 952 |
+
trimData = null;
|
|
|
|
|
|
|
|
|
|
| 953 |
document.removeEventListener('mousemove', handleTrim);
|
| 954 |
document.removeEventListener('mouseup', endTrim);
|
| 955 |
}
|
| 956 |
|
|
|
|
| 957 |
function updateDuration() {
|
| 958 |
+
totalDuration = timelineClips.length === 0 ? 0 : Math.max(...timelineClips.map(c => c.startTime + (c.trimEnd - c.trimStart)));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 959 |
document.getElementById('durationDisplay').textContent = formatTime(totalDuration);
|
| 960 |
}
|
| 961 |
|
| 962 |
function togglePlay() {
|
| 963 |
isPlaying = !isPlaying;
|
| 964 |
const icon = document.getElementById('playIcon');
|
| 965 |
+
icon.innerHTML = isPlaying ? '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>' : '<polygon points="5 3 19 12 5 21 5 3"/>';
|
| 966 |
+
isPlaying ? startPlayback() : stopPlayback();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
}
|
| 968 |
|
| 969 |
function startPlayback() {
|
| 970 |
let lastTime = performance.now();
|
|
|
|
| 971 |
function animate(now) {
|
| 972 |
if (!isPlaying) return;
|
| 973 |
+
currentTime += (now - lastTime) / 1000;
|
|
|
|
| 974 |
lastTime = now;
|
| 975 |
+
if (currentTime >= totalDuration) { currentTime = 0; if (totalDuration === 0) { isPlaying = false; document.getElementById('playIcon').innerHTML = '<polygon points="5 3 19 12 5 21 5 3"/>'; return; } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 976 |
updatePlayhead();
|
| 977 |
updatePreview();
|
|
|
|
| 978 |
animationId = requestAnimationFrame(animate);
|
| 979 |
}
|
|
|
|
| 980 |
animationId = requestAnimationFrame(animate);
|
| 981 |
}
|
| 982 |
|
| 983 |
function stopPlayback() {
|
| 984 |
+
if (animationId) { cancelAnimationFrame(animationId); animationId = null; }
|
| 985 |
+
const video = document.querySelector('#previewContainer video');
|
| 986 |
+
if (video && !video.paused) video.pause();
|
|
|
|
| 987 |
}
|
| 988 |
|
| 989 |
function updatePlayhead() {
|
| 990 |
+
document.getElementById('playhead').style.left = `${70 + currentTime * pixelsPerSecond * zoom}px`;
|
|
|
|
|
|
|
| 991 |
document.getElementById('currentTimeDisplay').textContent = formatTime(currentTime);
|
| 992 |
}
|
| 993 |
|
| 994 |
function updatePreview() {
|
| 995 |
const container = document.getElementById('previewContainer');
|
| 996 |
+
const current = timelineClips.filter(c => currentTime >= c.startTime && currentTime < c.startTime + (c.trimEnd - c.trimStart));
|
| 997 |
+
const visual = current.find(c => c.type === 'video' || c.type === 'image');
|
|
|
|
|
|
|
| 998 |
|
| 999 |
+
if (visual) {
|
| 1000 |
+
const clipTime = currentTime - visual.startTime + visual.trimStart;
|
| 1001 |
+
if (visual.type === 'image') {
|
| 1002 |
+
if (!container.querySelector(`img[data-clip-id="${visual.id}"]`)) container.innerHTML = `<img src="${visual.url}" data-clip-id="${visual.id}">`;
|
| 1003 |
+
} else {
|
| 1004 |
+
let video = container.querySelector(`video[data-clip-id="${visual.id}"]`);
|
| 1005 |
+
if (!video) { container.innerHTML = `<video src="${visual.url}" data-clip-id="${visual.id}" ${isMuted ? 'muted' : ''}></video>`; video = container.querySelector('video'); }
|
| 1006 |
+
if (Math.abs(video.currentTime - clipTime) > 0.2) video.currentTime = clipTime;
|
| 1007 |
+
if (isPlaying && video.paused) video.play().catch(() => {});
|
| 1008 |
+
else if (!isPlaying && !video.paused) video.pause();
|
| 1009 |
+
video.volume = isMuted ? 0 : visual.volume;
|
| 1010 |
+
video.muted = isMuted;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1011 |
}
|
| 1012 |
+
} else if (!current.some(c => c.type === 'video' || c.type === 'image')) {
|
| 1013 |
+
if (!container.querySelector('.preview-placeholder')) container.innerHTML = `<div class="preview-placeholder"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><rect x="2" y="2" width="20" height="20" rx="2"/><polygon points="10 8 16 12 10 16 10 8"/></svg><p>${current.length > 0 ? '๐ต ์ค๋์ค ์ฌ์ ์ค' : 'ํ์๋ผ์ธ์ ๋ฏธ๋์ด๋ฅผ ์ถ๊ฐํ์ธ์'}</p></div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1014 |
}
|
| 1015 |
}
|
| 1016 |
|
| 1017 |
+
function skipToStart() { currentTime = 0; updatePlayhead(); updatePreview(); }
|
| 1018 |
+
function skipToEnd() { currentTime = totalDuration; updatePlayhead(); updatePreview(); }
|
| 1019 |
+
function skipBackward() { currentTime = Math.max(0, currentTime - 5); updatePlayhead(); updatePreview(); }
|
| 1020 |
+
function skipForward() { currentTime = Math.min(totalDuration, currentTime + 5); updatePlayhead(); updatePreview(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1021 |
|
| 1022 |
function toggleMute() {
|
| 1023 |
isMuted = !isMuted;
|
| 1024 |
+
document.getElementById('volumeIcon').innerHTML = isMuted ? '<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/>' : '<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1025 |
const video = document.querySelector('#previewContainer video');
|
| 1026 |
if (video) video.muted = isMuted;
|
| 1027 |
}
|
| 1028 |
|
| 1029 |
+
function setZoom(value) { zoom = parseFloat(value); renderTimeline(); updatePlayhead(); }
|
|
|
|
|
|
|
|
|
|
| 1030 |
|
| 1031 |
+
function showContextMenu(x, y) { const menu = document.getElementById('contextMenu'); menu.style.display = 'block'; menu.style.left = `${x}px`; menu.style.top = `${y}px`; }
|
| 1032 |
+
function hideContextMenu() { document.getElementById('contextMenu').style.display = 'none'; }
|
| 1033 |
+
document.addEventListener('click', e => { if (!e.target.closest('.context-menu')) hideContextMenu(); });
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1034 |
|
| 1035 |
+
document.getElementById('timelineContainer').addEventListener('click', function(e) {
|
| 1036 |
+
if (e.target.closest('.timeline-clip')) return;
|
| 1037 |
+
currentTime = Math.max(0, Math.min(totalDuration, (e.clientX - this.getBoundingClientRect().left - 70 + this.scrollLeft) / (pixelsPerSecond * zoom)));
|
| 1038 |
+
updatePlayhead();
|
| 1039 |
+
updatePreview();
|
|
|
|
|
|
|
|
|
|
| 1040 |
});
|
| 1041 |
|
|
|
|
| 1042 |
async function exportVideo() {
|
| 1043 |
+
if (timelineClips.length === 0) { alert('ํ์๋ผ์ธ์ ํด๋ฆฝ์ ์ถ๊ฐํด์ฃผ์ธ์.'); return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1044 |
document.getElementById('exportModal').style.display = 'flex';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1045 |
for (let i = 0; i <= 100; i += 2) {
|
| 1046 |
await new Promise(r => setTimeout(r, 50));
|
| 1047 |
document.getElementById('exportProgress').style.width = `${i}%`;
|
|
|
|
| 1048 |
if (i === 30) document.getElementById('exportStatus').textContent = 'ํด๋ฆฝ ๋ณํฉ ์ค...';
|
| 1049 |
if (i === 60) document.getElementById('exportStatus').textContent = '์ค๋์ค ์ฒ๋ฆฌ ์ค...';
|
| 1050 |
if (i === 90) document.getElementById('exportStatus').textContent = '์ต์ข
๋ ๋๋ง ์ค...';
|
| 1051 |
}
|
| 1052 |
+
document.getElementById('exportStatus').textContent = 'โ
์๋ฃ!';
|
|
|
|
| 1053 |
document.getElementById('cancelExportBtn').textContent = '๋ซ๊ธฐ';
|
|
|
|
|
|
|
|
|
|
| 1054 |
}
|
| 1055 |
|
| 1056 |
+
function cancelExport() { document.getElementById('exportModal').style.display = 'none'; document.getElementById('cancelExportBtn').textContent = '์ทจ์'; }
|
|
|
|
|
|
|
|
|
|
| 1057 |
|
| 1058 |
+
document.addEventListener('keydown', function(e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1059 |
if (e.target.tagName === 'INPUT') return;
|
|
|
|
| 1060 |
switch(e.code) {
|
| 1061 |
+
case 'Space': e.preventDefault(); togglePlay(); break;
|
| 1062 |
+
case 'Delete': case 'Backspace': e.preventDefault(); if (selectedClipId) deleteSelectedClip(); break;
|
| 1063 |
+
case 'KeyD': if (e.ctrlKey || e.metaKey) { e.preventDefault(); if (selectedClipId) duplicateSelectedClip(); } break;
|
| 1064 |
+
case 'KeyZ': if (e.ctrlKey || e.metaKey) { e.preventDefault(); undoAction(); } break;
|
| 1065 |
+
case 'ArrowLeft': e.preventDefault(); currentTime = Math.max(0, currentTime - (e.shiftKey ? 1 : 0.1)); updatePlayhead(); updatePreview(); break;
|
| 1066 |
+
case 'ArrowRight': e.preventDefault(); currentTime = Math.min(totalDuration, currentTime + (e.shiftKey ? 1 : 0.1)); updatePlayhead(); updatePreview(); break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1067 |
}
|
| 1068 |
});
|
|
|
|
|
|
|
|
|
|
| 1069 |
</script>
|
| 1070 |
</body>
|
| 1071 |
</html>
|
|
|
|
| 1073 |
|
| 1074 |
|
| 1075 |
def create_interface():
|
|
|
|
|
|
|
| 1076 |
with gr.Blocks(title="Simple Video Editor") as demo:
|
| 1077 |
gr.HTML(EDITOR_HTML)
|
|
|
|
| 1078 |
return demo
|
| 1079 |
|
| 1080 |
|
| 1081 |
if __name__ == "__main__":
|
| 1082 |
demo = create_interface()
|
| 1083 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
|
|
|
|
|
|
|
|
|
|
|
|