Spaces:
Paused

seawolf2357 commited on
Commit
d7c665f
ยท
verified ยท
1 Parent(s): b402aa2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1153 -240
app.py CHANGED
@@ -13,7 +13,12 @@ EDITOR_HTML = """
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;
@@ -23,6 +28,7 @@ EDITOR_HTML = """
23
  font-size: 13px;
24
  }
25
 
 
26
  .editor-container {
27
  display: flex;
28
  flex-direction: column;
@@ -30,6 +36,7 @@ EDITOR_HTML = """
30
  max-height: 850px;
31
  }
32
 
 
33
  .toolbar {
34
  height: 48px;
35
  background: #ffffff;
@@ -50,9 +57,18 @@ EDITOR_HTML = """
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;
@@ -66,16 +82,54 @@ EDITOR_HTML = """
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;
@@ -83,6 +137,7 @@ EDITOR_HTML = """
83
  background: #f5f5f7;
84
  }
85
 
 
86
  .media-library {
87
  width: 200px;
88
  background: #ffffff;
@@ -98,6 +153,7 @@ EDITOR_HTML = """
98
  font-weight: 600;
99
  color: #6b7280;
100
  text-transform: uppercase;
 
101
  }
102
 
103
  .library-content {
@@ -106,6 +162,7 @@ EDITOR_HTML = """
106
  padding: 8px;
107
  }
108
 
 
109
  .upload-zone {
110
  border: 2px dashed #d1d5db;
111
  border-radius: 8px;
@@ -117,10 +174,25 @@ EDITOR_HTML = """
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);
@@ -144,7 +216,16 @@ EDITOR_HTML = """
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;
@@ -157,8 +238,17 @@ EDITOR_HTML = """
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;
@@ -184,8 +274,13 @@ EDITOR_HTML = """
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;
@@ -207,11 +302,30 @@ EDITOR_HTML = """
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);
@@ -236,11 +350,30 @@ EDITOR_HTML = """
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;
@@ -250,6 +383,7 @@ EDITOR_HTML = """
250
  text-align: center;
251
  }
252
 
 
253
  .properties-panel {
254
  width: 180px;
255
  background: #ffffff;
@@ -265,11 +399,26 @@ EDITOR_HTML = """
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%;
@@ -281,11 +430,30 @@ EDITOR_HTML = """
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;
@@ -304,8 +472,15 @@ EDITOR_HTML = """
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;
@@ -316,8 +491,15 @@ EDITOR_HTML = """
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;
@@ -327,6 +509,7 @@ EDITOR_HTML = """
327
  background: #f9fafb;
328
  }
329
 
 
330
  .timeline-ruler {
331
  height: 22px;
332
  background: #fff;
@@ -336,7 +519,11 @@ EDITOR_HTML = """
336
  border-bottom: 1px solid #e5e7eb;
337
  }
338
 
339
- .timeline-tracks { position: relative; min-height: 120px; }
 
 
 
 
340
 
341
  .timeline-track {
342
  height: 55px;
@@ -347,7 +534,9 @@ EDITOR_HTML = """
347
  background: #fff;
348
  }
349
 
350
- .timeline-track:nth-child(2) { background: #fffbeb; }
 
 
351
 
352
  .track-label {
353
  width: 70px;
@@ -365,9 +554,19 @@ EDITOR_HTML = """
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;
@@ -382,17 +581,58 @@ EDITOR_HTML = """
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;
@@ -404,10 +644,21 @@ EDITOR_HTML = """
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;
@@ -429,13 +680,33 @@ EDITOR_HTML = """
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;
@@ -455,11 +726,31 @@ EDITOR_HTML = """
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;
@@ -480,96 +771,208 @@ EDITOR_HTML = """
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>
@@ -578,48 +981,102 @@ EDITOR_HTML = """
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;
601
- let isPlaying = false;
602
- let isMuted = false;
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);
625
  const secs = Math.floor(seconds % 60);
@@ -627,11 +1084,19 @@ EDITOR_HTML = """
627
  return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}.${ms.toString().padStart(2, '0')}`;
628
  }
629
 
 
 
 
630
  function saveState() {
631
  undoStack.push(JSON.stringify(timelineClips));
632
- if (undoStack.length > 50) undoStack.shift();
 
 
633
  }
634
 
 
 
 
635
  function undoAction() {
636
  if (undoStack.length > 0) {
637
  timelineClips = JSON.parse(undoStack.pop());
@@ -640,75 +1105,135 @@ EDITOR_HTML = """
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(),
668
  name: file.name,
669
  type: type,
670
  url: url,
671
  file: file,
672
- duration: type === 'image' ? 5 : 0,
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>'
@@ -720,31 +1245,61 @@ EDITOR_HTML = """
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,21 +1312,35 @@ EDITOR_HTML = """
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`);
777
  if (!trackEl) return;
@@ -780,18 +1349,45 @@ EDITOR_HTML = """
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
  `;
@@ -802,47 +1398,74 @@ EDITOR_HTML = """
802
  renderRuler();
803
  }
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);
830
 
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();
@@ -850,7 +1473,15 @@ EDITOR_HTML = """
850
  }
851
  }
852
 
853
- function selectClip(clipId) { selectedClipId = clipId; renderTimeline(); renderProperties(); }
 
 
 
 
 
 
 
 
854
 
855
  function renderProperties() {
856
  const container = document.getElementById('propertiesContent');
@@ -861,89 +1492,174 @@ EDITOR_HTML = """
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
  }
898
 
 
 
 
899
  function duplicateSelectedClip() {
900
  if (!selectedClipId) return;
 
901
  const clip = timelineClips.find(c => c.id === selectedClipId);
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();
909
  }
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
  }
@@ -954,116 +1670,306 @@ EDITOR_HTML = """
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>
@@ -1073,11 +1979,18 @@ EDITOR_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)
 
 
 
 
 
13
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
14
  <title>Simple Video Editor</title>
15
  <style>
16
+ /* ========== ๊ธฐ๋ณธ ๋ฆฌ์…‹ ========== */
17
+ * {
18
+ margin: 0;
19
+ padding: 0;
20
+ box-sizing: border-box;
21
+ }
22
 
23
  body {
24
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
 
28
  font-size: 13px;
29
  }
30
 
31
+ /* ========== ์—๋””ํ„ฐ ์ปจํ…Œ์ด๋„ˆ ========== */
32
  .editor-container {
33
  display: flex;
34
  flex-direction: column;
 
36
  max-height: 850px;
37
  }
38
 
39
+ /* ========== ์ƒ๋‹จ ํˆด๋ฐ” ========== */
40
  .toolbar {
41
  height: 48px;
42
  background: #ffffff;
 
57
  gap: 6px;
58
  }
59
 
60
+ .toolbar-title svg {
61
+ width: 20px;
62
+ height: 20px;
63
+ color: #6366f1;
64
+ }
65
+
66
+ .toolbar-actions {
67
+ display: flex;
68
+ gap: 8px;
69
+ }
70
 
71
+ /* ========== ๋ฒ„ํŠผ ์Šคํƒ€์ผ ========== */
72
  .btn {
73
  padding: 6px 12px;
74
  border: none;
 
82
  transition: all 0.15s;
83
  }
84
 
85
+ .btn svg {
86
+ width: 14px;
87
+ height: 14px;
88
+ }
89
+
90
+ .btn-primary {
91
+ background: #6366f1;
92
+ color: white;
93
+ }
94
+
95
+ .btn-primary:hover {
96
+ background: #4f46e5;
97
+ }
98
+
99
+ .btn-success {
100
+ background: #10b981;
101
+ color: white;
102
+ }
103
+
104
+ .btn-success:hover {
105
+ background: #059669;
106
+ }
107
+
108
+ .btn-danger {
109
+ background: #ef4444;
110
+ color: white;
111
+ }
112
+
113
+ .btn-danger:hover {
114
+ background: #dc2626;
115
+ }
116
+
117
+ .btn-secondary {
118
+ background: #f3f4f6;
119
+ color: #374151;
120
+ border: 1px solid #e5e7eb;
121
+ }
122
+
123
+ .btn-secondary:hover {
124
+ background: #e5e7eb;
125
+ }
126
+
127
+ .btn:disabled {
128
+ opacity: 0.5;
129
+ cursor: not-allowed;
130
+ }
131
 
132
+ /* ========== ๋ฉ”์ธ ์˜์—ญ ========== */
133
  .main-area {
134
  display: flex;
135
  flex: 1;
 
137
  background: #f5f5f7;
138
  }
139
 
140
+ /* ========== ๋ฏธ๋””์–ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ========== */
141
  .media-library {
142
  width: 200px;
143
  background: #ffffff;
 
153
  font-weight: 600;
154
  color: #6b7280;
155
  text-transform: uppercase;
156
+ letter-spacing: 0.5px;
157
  }
158
 
159
  .library-content {
 
162
  padding: 8px;
163
  }
164
 
165
+ /* ========== ์—…๋กœ๋“œ ์˜์—ญ ========== */
166
  .upload-zone {
167
  border: 2px dashed #d1d5db;
168
  border-radius: 8px;
 
174
  background: #fafafa;
175
  }
176
 
177
+ .upload-zone:hover {
178
+ border-color: #6366f1;
179
+ background: #f0f0ff;
180
+ }
181
+
182
+ .upload-zone svg {
183
+ width: 24px;
184
+ height: 24px;
185
+ color: #9ca3af;
186
+ margin-bottom: 6px;
187
+ }
188
+
189
+ .upload-zone p {
190
+ font-size: 11px;
191
+ color: #6b7280;
192
+ line-height: 1.4;
193
+ }
194
 
195
+ /* ========== ๋ฏธ๋””์–ด ๊ทธ๋ฆฌ๋“œ ========== */
196
  .media-grid {
197
  display: grid;
198
  grid-template-columns: repeat(2, 1fr);
 
216
  border-color: #6366f1;
217
  }
218
 
219
+ .media-item:active {
220
+ cursor: grabbing;
221
+ }
222
+
223
+ .media-item img,
224
+ .media-item video {
225
+ width: 100%;
226
+ height: 100%;
227
+ object-fit: cover;
228
+ }
229
 
230
  .media-item-overlay {
231
  position: absolute;
 
238
  padding: 4px;
239
  }
240
 
241
+ .media-item:hover .media-item-overlay {
242
+ opacity: 1;
243
+ }
244
+
245
+ .media-item-name {
246
+ font-size: 9px;
247
+ color: white;
248
+ white-space: nowrap;
249
+ overflow: hidden;
250
+ text-overflow: ellipsis;
251
+ }
252
 
253
  .media-item-duration {
254
  position: absolute;
 
274
  justify-content: center;
275
  }
276
 
277
+ .media-item-type svg {
278
+ width: 10px;
279
+ height: 10px;
280
+ color: white;
281
+ }
282
 
283
+ /* ========== ํ”„๋ฆฌ๋ทฐ ์˜์—ญ ========== */
284
  .preview-area {
285
  flex: 1;
286
  display: flex;
 
302
  background: #000;
303
  }
304
 
305
+ .preview-container video,
306
+ .preview-container img {
307
+ max-width: 100%;
308
+ max-height: 100%;
309
+ object-fit: contain;
310
+ }
311
+
312
+ .preview-placeholder {
313
+ text-align: center;
314
+ color: #666;
315
+ }
316
+
317
+ .preview-placeholder svg {
318
+ width: 48px;
319
+ height: 48px;
320
+ margin-bottom: 12px;
321
+ opacity: 0.5;
322
+ }
323
+
324
+ .preview-placeholder p {
325
+ font-size: 12px;
326
+ }
327
 
328
+ /* ========== ์žฌ์ƒ ์ปจํŠธ๋กค ========== */
329
  .playback-controls {
330
  height: 50px;
331
  background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
 
350
  transition: all 0.15s;
351
  }
352
 
353
+ .control-btn:hover {
354
+ background: rgba(255,255,255,0.2);
355
+ }
356
+
357
+ .control-btn svg {
358
+ width: 14px;
359
+ height: 14px;
360
+ }
361
+
362
+ .control-btn.play-btn {
363
+ width: 40px;
364
+ height: 40px;
365
+ background: #6366f1;
366
+ }
367
+
368
+ .control-btn.play-btn:hover {
369
+ background: #4f46e5;
370
+ transform: scale(1.05);
371
+ }
372
+
373
+ .control-btn.play-btn svg {
374
+ width: 18px;
375
+ height: 18px;
376
+ }
377
 
378
  .time-display {
379
  font-family: 'SF Mono', Monaco, monospace;
 
383
  text-align: center;
384
  }
385
 
386
+ /* ========== ์†์„ฑ ํŒจ๋„ ========== */
387
  .properties-panel {
388
  width: 180px;
389
  background: #ffffff;
 
399
  font-weight: 600;
400
  color: #6b7280;
401
  text-transform: uppercase;
402
+ letter-spacing: 0.5px;
403
  }
404
 
405
+ .properties-content {
406
+ flex: 1;
407
+ padding: 12px;
408
+ overflow-y: auto;
409
+ }
410
+
411
+ .property-group {
412
+ margin-bottom: 14px;
413
+ }
414
+
415
+ .property-label {
416
+ font-size: 10px;
417
+ color: #6b7280;
418
+ margin-bottom: 4px;
419
+ text-transform: uppercase;
420
+ letter-spacing: 0.3px;
421
+ }
422
 
423
  .property-input {
424
  width: 100%;
 
430
  font-size: 12px;
431
  }
432
 
433
+ .property-input:focus {
434
+ outline: none;
435
+ border-color: #6366f1;
436
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
437
+ }
438
 
439
+ .property-row {
440
+ display: flex;
441
+ gap: 8px;
442
+ }
443
+
444
+ .property-row > div {
445
+ flex: 1;
446
+ }
447
+
448
+ .no-selection {
449
+ color: #9ca3af;
450
+ text-align: center;
451
+ padding: 30px 15px;
452
+ font-size: 12px;
453
+ line-height: 1.5;
454
+ }
455
+
456
+ /* ========== ํƒ€์ž„๋ผ์ธ ์˜์—ญ ========== */
457
  .timeline-area {
458
  height: 180px;
459
  background: #ffffff;
 
472
  gap: 6px;
473
  }
474
 
475
+ .timeline-toolbar .btn {
476
+ padding: 4px 8px;
477
+ font-size: 11px;
478
+ }
479
+
480
+ .timeline-toolbar .btn svg {
481
+ width: 12px;
482
+ height: 12px;
483
+ }
484
 
485
  .timeline-zoom {
486
  display: flex;
 
491
  color: #6b7280;
492
  }
493
 
494
+ .timeline-zoom input {
495
+ width: 60px;
496
+ height: 4px;
497
+ }
498
+
499
+ .timeline-zoom svg {
500
+ width: 12px;
501
+ height: 12px;
502
+ }
503
 
504
  .timeline-container {
505
  flex: 1;
 
509
  background: #f9fafb;
510
  }
511
 
512
+ /* ========== ํƒ€์ž„๋ผ์ธ ๋ˆˆ๊ธˆ์ž ========== */
513
  .timeline-ruler {
514
  height: 22px;
515
  background: #fff;
 
519
  border-bottom: 1px solid #e5e7eb;
520
  }
521
 
522
+ /* ========== ํƒ€์ž„๋ผ์ธ ํŠธ๋ž™ ========== */
523
+ .timeline-tracks {
524
+ position: relative;
525
+ min-height: 120px;
526
+ }
527
 
528
  .timeline-track {
529
  height: 55px;
 
534
  background: #fff;
535
  }
536
 
537
+ .timeline-track:nth-child(2) {
538
+ background: #fffbeb;
539
+ }
540
 
541
  .track-label {
542
  width: 70px;
 
554
  z-index: 5;
555
  }
556
 
557
+ .track-label svg {
558
+ width: 12px;
559
+ height: 12px;
560
+ }
561
+
562
+ .track-content {
563
+ flex: 1;
564
+ height: 100%;
565
+ position: relative;
566
+ min-width: 800px;
567
+ }
568
 
569
+ /* ========== ํƒ€์ž„๋ผ์ธ ํด๋ฆฝ ========== */
570
  .timeline-clip {
571
  position: absolute;
572
  height: 45px;
 
581
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
582
  }
583
 
584
+ .timeline-clip:active {
585
+ cursor: grabbing;
586
+ }
587
+
588
+ .timeline-clip:hover {
589
+ box-shadow: 0 0 0 2px #6366f1;
590
+ }
591
 
592
+ .timeline-clip.selected {
593
+ box-shadow: 0 0 0 2px #6366f1, 0 4px 12px rgba(99, 102, 241, 0.3);
594
+ }
595
+
596
+ .timeline-clip.video {
597
+ background: linear-gradient(135deg, #818cf8, #6366f1);
598
+ }
599
+
600
+ .timeline-clip.image {
601
+ background: linear-gradient(135deg, #34d399, #10b981);
602
+ }
603
+
604
+ .timeline-clip.audio {
605
+ background: linear-gradient(135deg, #fbbf24, #f59e0b);
606
+ }
607
+
608
+ .clip-thumbnail {
609
+ width: 45px;
610
+ height: 100%;
611
+ object-fit: cover;
612
+ flex-shrink: 0;
613
+ }
614
+
615
+ .clip-info {
616
+ padding: 0 6px;
617
+ flex: 1;
618
+ overflow: hidden;
619
+ }
620
+
621
+ .clip-name {
622
+ font-size: 10px;
623
+ font-weight: 500;
624
+ color: white;
625
+ white-space: nowrap;
626
+ overflow: hidden;
627
+ text-overflow: ellipsis;
628
+ }
629
+
630
+ .clip-duration {
631
+ font-size: 9px;
632
+ color: rgba(255,255,255,0.7);
633
+ }
634
 
635
+ /* ========== ํด๋ฆฝ ํŠธ๋ฆผ ํ•ธ๋“ค ========== */
636
  .clip-handles {
637
  position: absolute;
638
  top: 0;
 
644
  transition: opacity 0.15s;
645
  }
646
 
647
+ .timeline-clip:hover .clip-handles {
648
+ opacity: 1;
649
+ }
650
+
651
+ .clip-handle-left {
652
+ left: 0;
653
+ border-radius: 6px 0 0 6px;
654
+ }
655
+
656
+ .clip-handle-right {
657
+ right: 0;
658
+ border-radius: 0 6px 6px 0;
659
+ }
660
 
661
+ /* ========== ํ”Œ๋ ˆ์ดํ—ค๋“œ ========== */
662
  .playhead {
663
  position: absolute;
664
  top: 0;
 
680
  clip-path: polygon(50% 100%, 0 0, 100% 0);
681
  }
682
 
683
+ /* ========== ์Šคํฌ๋กค๋ฐ” ์Šคํƒ€์ผ ========== */
684
+ ::-webkit-scrollbar {
685
+ width: 6px;
686
+ height: 6px;
687
+ }
688
+
689
+ ::-webkit-scrollbar-track {
690
+ background: #f1f1f1;
691
+ }
692
+
693
+ ::-webkit-scrollbar-thumb {
694
+ background: #c1c1c1;
695
+ border-radius: 3px;
696
+ }
697
+
698
+ ::-webkit-scrollbar-thumb:hover {
699
+ background: #a1a1a1;
700
+ }
701
 
702
+ /* ========== ๋“œ๋กญ์กด ํ•˜์ด๋ผ์ดํŠธ ========== */
703
+ .drop-highlight {
704
+ background: rgba(99, 102, 241, 0.1) !important;
705
+ outline: 2px dashed #6366f1 !important;
706
+ outline-offset: -2px;
707
+ }
708
 
709
+ /* ========== ๋ชจ๋‹ฌ ========== */
710
  .modal-overlay {
711
  position: fixed;
712
  inset: 0;
 
726
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
727
  }
728
 
729
+ .modal h3 {
730
+ margin-bottom: 12px;
731
+ font-size: 16px;
732
+ }
733
+
734
+ .modal p {
735
+ font-size: 13px;
736
+ color: #6b7280;
737
+ }
738
 
739
+ .progress-bar {
740
+ height: 6px;
741
+ background: #e5e7eb;
742
+ border-radius: 3px;
743
+ overflow: hidden;
744
+ margin: 16px 0;
745
+ }
746
+
747
+ .progress-fill {
748
+ height: 100%;
749
+ background: linear-gradient(90deg, #6366f1, #8b5cf6);
750
+ transition: width 0.3s;
751
+ }
752
+
753
+ /* ========== ์ปจํ…์ŠคํŠธ ๋ฉ”๋‰ด ========== */
754
  .context-menu {
755
  position: fixed;
756
  background: #fff;
 
771
  font-size: 12px;
772
  }
773
 
774
+ .context-menu-item:hover {
775
+ background: #f3f4f6;
776
+ }
777
+
778
+ .context-menu-item svg {
779
+ width: 12px;
780
+ height: 12px;
781
+ }
782
+
783
+ .context-menu-item.danger {
784
+ color: #ef4444;
785
+ }
786
+
787
+ .context-menu-divider {
788
+ height: 1px;
789
+ background: #e5e7eb;
790
+ margin: 4px 0;
791
+ }
792
+
793
+ /* ========== ํŒŒ์ผ ์ž…๋ ฅ ์ˆจ๊ธฐ๊ธฐ ========== */
794
+ #fileInput {
795
+ display: none;
796
+ }
797
  </style>
798
  </head>
799
  <body>
800
  <div class="editor-container">
801
+ <!-- ========== ์ƒ๋‹จ ํˆด๋ฐ” ========== -->
802
  <div class="toolbar">
803
  <div class="toolbar-title">
804
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
805
+ <rect x="2" y="2" width="20" height="20" rx="2"/>
806
+ <line x1="7" y1="2" x2="7" y2="22"/>
807
+ <line x1="17" y1="2" x2="17" y2="22"/>
808
+ <line x1="2" y1="12" x2="22" y2="12"/>
809
+ </svg>
810
  Simple Video Editor
811
  </div>
812
  <div class="toolbar-actions">
813
+ <button class="btn btn-secondary" onclick="undoAction()" title="Ctrl+Z">
814
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
815
+ <path d="M3 7v6h6M3 13a9 9 0 1 0 2.5-6.5"/>
816
+ </svg>
817
  ์‹คํ–‰์ทจ์†Œ
818
  </button>
819
+ <label class="btn btn-primary" for="fileInput" style="cursor:pointer">
820
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
821
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"/>
822
+ </svg>
823
  ํŒŒ์ผ ์ถ”๊ฐ€
824
  </label>
825
  <input type="file" id="fileInput" multiple accept="video/*,image/*,audio/*">
826
+ <button class="btn btn-success" onclick="exportVideo()" id="exportBtn">
827
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
828
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3"/>
829
+ </svg>
830
  ๋‚ด๋ณด๋‚ด๊ธฐ
831
  </button>
832
  </div>
833
  </div>
834
 
835
+ <!-- ========== ๋ฉ”์ธ ์˜์—ญ ========== -->
836
  <div class="main-area">
837
+ <!-- ๋ฏธ๋””์–ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ -->
838
  <div class="media-library">
839
  <div class="library-header">๐Ÿ“ ๋ฏธ๋””์–ด</div>
840
  <div class="library-content">
841
  <label class="upload-zone" for="fileInput">
842
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
843
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"/>
844
+ </svg>
845
  <p>ํด๋ฆญ ๋˜๋Š” ๋“œ๋ž˜๊ทธ<br>์˜์ƒ/์ด๋ฏธ์ง€/์˜ค๋””์˜ค</p>
846
  </label>
847
  <div class="media-grid" id="mediaGrid"></div>
848
  </div>
849
  </div>
850
 
851
+ <!-- ํ”„๋ฆฌ๋ทฐ + ์ปจํŠธ๋กค -->
852
  <div class="preview-area">
853
  <div class="preview-container" id="previewContainer">
854
  <div class="preview-placeholder">
855
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1">
856
+ <rect x="2" y="2" width="20" height="20" rx="2"/>
857
+ <polygon points="10 8 16 12 10 16 10 8"/>
858
+ </svg>
859
  <p>ํƒ€์ž„๋ผ์ธ์— ๋ฏธ๋””์–ด๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”</p>
860
  </div>
861
  </div>
862
 
863
  <div class="playback-controls">
864
+ <button class="control-btn" onclick="skipToStart()" title="์ฒ˜์Œ์œผ๋กœ">
865
+ <svg viewBox="0 0 24 24" fill="currentColor">
866
+ <path d="M6 6h2v12H6zm3.5 6l8.5 6V6z"/>
867
+ </svg>
868
+ </button>
869
+ <button class="control-btn" onclick="skipBackward()" title="-5์ดˆ">
870
+ <svg viewBox="0 0 24 24" fill="currentColor">
871
+ <path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/>
872
+ </svg>
873
+ </button>
874
+ <button class="control-btn play-btn" onclick="togglePlay()" id="playBtn" title="Space">
875
+ <svg viewBox="0 0 24 24" fill="currentColor" id="playIcon">
876
+ <polygon points="5 3 19 12 5 21 5 3"/>
877
+ </svg>
878
+ </button>
879
+ <button class="control-btn" onclick="skipForward()" title="+5์ดˆ">
880
+ <svg viewBox="0 0 24 24" fill="currentColor">
881
+ <path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/>
882
+ </svg>
883
+ </button>
884
+ <button class="control-btn" onclick="skipToEnd()" title="๋์œผ๋กœ">
885
+ <svg viewBox="0 0 24 24" fill="currentColor">
886
+ <path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/>
887
+ </svg>
888
+ </button>
889
+ <div class="time-display">
890
+ <span id="currentTimeDisplay">00:00.00</span> / <span id="durationDisplay">00:00.00</span>
891
+ </div>
892
+ <button class="control-btn" onclick="toggleMute()" id="muteBtn" title="์Œ์†Œ๊ฑฐ">
893
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" id="volumeIcon">
894
+ <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/>
895
+ <path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/>
896
+ </svg>
897
+ </button>
898
  </div>
899
  </div>
900
 
901
+ <!-- ์†์„ฑ ํŒจ๋„ -->
902
  <div class="properties-panel">
903
  <div class="properties-header">โš™๏ธ ์†์„ฑ</div>
904
  <div class="properties-content" id="propertiesContent">
905
+ <div class="no-selection">
906
+ ํด๋ฆฝ์„ ์„ ํƒํ•˜๋ฉด<br>์†์„ฑ์„ ํŽธ์ง‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค
907
+ </div>
908
  </div>
909
  </div>
910
  </div>
911
 
912
+ <!-- ========== ํƒ€์ž„๋ผ์ธ ========== -->
913
  <div class="timeline-area">
914
  <div class="timeline-toolbar">
915
+ <button class="btn btn-secondary" onclick="splitSelectedClip()" title="์„ ํƒ ํด๋ฆฝ ์ž๋ฅด๊ธฐ">
916
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
917
+ <circle cx="6" cy="6" r="3"/>
918
+ <circle cx="6" cy="18" r="3"/>
919
+ <line x1="20" y1="4" x2="8.12" y2="15.88"/>
920
+ <line x1="14.47" y1="14.48" x2="20" y2="20"/>
921
+ <line x1="8.12" y1="8.12" x2="12" y2="12"/>
922
+ </svg>
923
+ ์ž๋ฅด๊ธฐ
924
+ </button>
925
+ <button class="btn btn-secondary" onclick="duplicateSelectedClip()" title="Ctrl+D">
926
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
927
+ <rect x="9" y="9" width="13" height="13" rx="2"/>
928
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
929
+ </svg>
930
+ ๋ณต์ œ
931
+ </button>
932
+ <button class="btn btn-danger" onclick="deleteSelectedClip()" title="Delete">
933
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
934
+ <polyline points="3 6 5 6 21 6"/>
935
+ <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"/>
936
+ </svg>
937
+ ์‚ญ์ œ
938
+ </button>
939
  <div class="timeline-zoom">
940
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
941
+ <circle cx="11" cy="11" r="8"/>
942
+ <line x1="21" y1="21" x2="16.65" y2="16.65"/>
943
+ <line x1="8" y1="11" x2="14" y2="11"/>
944
+ </svg>
945
+ <input type="range" min="0.5" max="3" step="0.1" value="1" oninput="setZoom(this.value)" id="zoomSlider">
946
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
947
+ <circle cx="11" cy="11" r="8"/>
948
+ <line x1="21" y1="21" x2="16.65" y2="16.65"/>
949
+ <line x1="11" y1="8" x2="11" y2="14"/>
950
+ <line x1="8" y1="11" x2="14" y2="11"/>
951
+ </svg>
952
  </div>
953
  </div>
954
  <div class="timeline-container" id="timelineContainer">
955
  <div class="timeline-ruler" id="timelineRuler"></div>
956
  <div class="timeline-tracks" id="timelineTracks">
957
  <div class="timeline-track" data-track="0">
958
+ <div class="track-label">
959
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
960
+ <polygon points="23 7 16 12 23 17 23 7"/>
961
+ <rect x="1" y="5" width="15" height="14" rx="2"/>
962
+ </svg>
963
+ ์˜์ƒ
964
+ </div>
965
  <div class="track-content" ondragover="handleDragOver(event)" ondrop="handleDrop(event, 0)" ondragleave="handleDragLeave(event)"></div>
966
  </div>
967
  <div class="timeline-track" data-track="1">
968
+ <div class="track-label">
969
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
970
+ <path d="M9 18V5l12-2v13"/>
971
+ <circle cx="6" cy="18" r="3"/>
972
+ <circle cx="18" cy="16" r="3"/>
973
+ </svg>
974
+ ์˜ค๋””์˜ค
975
+ </div>
976
  <div class="track-content" ondragover="handleDragOver(event)" ondrop="handleDrop(event, 1)" ondragleave="handleDragLeave(event)"></div>
977
  </div>
978
  </div>
 
981
  </div>
982
  </div>
983
 
984
+ <!-- ========== ์ปจํ…์ŠคํŠธ ๋ฉ”๋‰ด ========== -->
985
  <div class="context-menu" id="contextMenu" style="display:none;">
986
+ <div class="context-menu-item" onclick="splitSelectedClip()">
987
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
988
+ <circle cx="6" cy="6" r="3"/>
989
+ <circle cx="6" cy="18" r="3"/>
990
+ <line x1="20" y1="4" x2="8.12" y2="15.88"/>
991
+ </svg>
992
+ ์ž๋ฅด๊ธฐ
993
+ </div>
994
+ <div class="context-menu-item" onclick="duplicateSelectedClip()">
995
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
996
+ <rect x="9" y="9" width="13" height="13" rx="2"/>
997
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
998
+ </svg>
999
+ ๋ณต์ œ
1000
+ </div>
1001
  <div class="context-menu-divider"></div>
1002
+ <div class="context-menu-item danger" onclick="deleteSelectedClip()">
1003
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1004
+ <polyline points="3 6 5 6 21 6"/>
1005
+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/>
1006
+ </svg>
1007
+ ์‚ญ์ œ
1008
+ </div>
1009
  </div>
1010
 
1011
+ <!-- ========== ๋‚ด๋ณด๋‚ด๊ธฐ ๋ชจ๋‹ฌ ========== -->
1012
  <div class="modal-overlay" id="exportModal" style="display:none;">
1013
  <div class="modal">
1014
  <h3>๐ŸŽฌ ์˜์ƒ ๋‚ด๋ณด๋‚ด๊ธฐ</h3>
1015
  <p id="exportStatus">์˜์ƒ์„ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค...</p>
1016
+ <div class="progress-bar">
1017
+ <div class="progress-fill" id="exportProgress" style="width: 0%"></div>
1018
+ </div>
1019
  <button class="btn btn-secondary" onclick="cancelExport()" id="cancelExportBtn">์ทจ์†Œ</button>
1020
  </div>
1021
  </div>
1022
 
1023
  <script>
1024
+ // ========================================
1025
+ // ์ƒํƒœ ๊ด€๋ฆฌ ๋ณ€์ˆ˜
1026
+ // ========================================
1027
+ let mediaLibrary = []; // ์—…๋กœ๋“œ๋œ ๋ฏธ๋””์–ด ๋ชฉ๋ก
1028
+ let timelineClips = []; // ํƒ€์ž„๋ผ์ธ ํด๋ฆฝ ๋ชฉ๋ก
1029
+ let selectedClipId = null; // ์„ ํƒ๋œ ํด๋ฆฝ ID
1030
+ let isPlaying = false; // ์žฌ์ƒ ์ƒํƒœ
1031
+ let isMuted = false; // ์Œ์†Œ๊ฑฐ ์ƒํƒœ
1032
+ let currentTime = 0; // ํ˜„์žฌ ์žฌ์ƒ ์‹œ๊ฐ„
1033
+ let totalDuration = 0; // ์ „์ฒด ๊ธธ์ด
1034
+ let zoom = 1; // ํƒ€์ž„๋ผ์ธ ์คŒ ๋ ˆ๋ฒจ
1035
+ let pixelsPerSecond = 80; // ์ดˆ๋‹น ํ”ฝ์…€
1036
+ let undoStack = []; // ์‹คํ–‰์ทจ์†Œ ์Šคํƒ
1037
+ let animationId = null; // ์• ๋‹ˆ๋ฉ”์ด์…˜ ํ”„๋ ˆ์ž„ ID
1038
+ let trimData = null; // ํŠธ๋ฆผ ์ž‘์—… ๋ฐ์ดํ„ฐ
1039
+
1040
+ // ========================================
1041
+ // ์ดˆ๊ธฐํ™”
1042
+ // ========================================
1043
  document.addEventListener('DOMContentLoaded', function() {
1044
+ // ํŒŒ์ผ ์ž…๋ ฅ ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ
1045
+ const fileInput = document.getElementById('fileInput');
1046
+ fileInput.addEventListener('change', handleFileUpload);
1047
+
1048
+ // ๋“œ๋ž˜๊ทธ์•ค๋“œ๋กญ ์ „์—ญ ์„ค์ •
1049
+ document.addEventListener('dragover', function(e) {
1050
+ e.preventDefault();
1051
+ });
1052
+
1053
  document.addEventListener('drop', function(e) {
1054
  e.preventDefault();
1055
+ if (e.target.closest('.upload-zone') || e.target.closest('.library-content')) {
1056
+ handleFileDrop(e);
1057
+ }
1058
  });
1059
+
1060
+ // ์ดˆ๊ธฐ ํƒ€์ž„๋ผ์ธ ๋ Œ๋”๋ง
1061
  renderTimeline();
1062
+
1063
+ console.log('๐ŸŽฌ Simple Video Editor ์ดˆ๊ธฐํ™” ์™„๋ฃŒ');
1064
  });
1065
 
1066
+ // ========================================
1067
+ // ์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜
1068
+ // ========================================
1069
+
1070
+ /**
1071
+ * ๊ณ ์œ  ID ์ƒ์„ฑ
1072
+ */
1073
+ function generateId() {
1074
+ return Date.now().toString(36) + Math.random().toString(36).substr(2);
1075
+ }
1076
 
1077
+ /**
1078
+ * ์‹œ๊ฐ„ ํฌ๋งทํŒ… (์ดˆ -> mm:ss.ms)
1079
+ */
1080
  function formatTime(seconds) {
1081
  const mins = Math.floor(seconds / 60);
1082
  const secs = Math.floor(seconds % 60);
 
1084
  return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}.${ms.toString().padStart(2, '0')}`;
1085
  }
1086
 
1087
+ /**
1088
+ * ํ˜„์žฌ ์ƒํƒœ ์ €์žฅ (์‹คํ–‰์ทจ์†Œ์šฉ)
1089
+ */
1090
  function saveState() {
1091
  undoStack.push(JSON.stringify(timelineClips));
1092
+ if (undoStack.length > 50) {
1093
+ undoStack.shift();
1094
+ }
1095
  }
1096
 
1097
+ /**
1098
+ * ์‹คํ–‰์ทจ์†Œ
1099
+ */
1100
  function undoAction() {
1101
  if (undoStack.length > 0) {
1102
  timelineClips = JSON.parse(undoStack.pop());
 
1105
  }
1106
  }
1107
 
1108
+ // ========================================
1109
+ // ํŒŒ์ผ ์—…๋กœ๋“œ ์ฒ˜๋ฆฌ
1110
+ // ========================================
1111
+
1112
+ /**
1113
+ * ํŒŒ์ผ ์ž…๋ ฅ ํ•ธ๋“ค๋Ÿฌ
1114
+ */
1115
  function handleFileUpload(event) {
1116
  const files = event.target.files;
1117
  if (!files || files.length === 0) return;
1118
+
1119
  processFiles(Array.from(files));
1120
+ event.target.value = ''; // ๋ฆฌ์…‹
1121
  }
1122
 
1123
+ /**
1124
+ * ํŒŒ์ผ ๋“œ๋กญ ํ•ธ๋“ค๋Ÿฌ
1125
+ */
1126
  function handleFileDrop(event) {
1127
  const files = event.dataTransfer.files;
1128
  if (!files || files.length === 0) return;
1129
+
1130
  processFiles(Array.from(files));
1131
  }
1132
 
1133
+ /**
1134
+ * ํŒŒ์ผ ์ฒ˜๋ฆฌ
1135
+ */
1136
  function processFiles(files) {
1137
+ console.log('๐Ÿ“ ํŒŒ์ผ ์ฒ˜๋ฆฌ ์‹œ์ž‘:', files.length, '๊ฐœ');
1138
 
1139
  files.forEach(file => {
1140
+ // ํŒŒ์ผ ํƒ€์ž… ํ™•์ธ
1141
+ let type = null;
1142
+ if (file.type.startsWith('video')) {
1143
+ type = 'video';
1144
+ } else if (file.type.startsWith('image')) {
1145
+ type = 'image';
1146
+ } else if (file.type.startsWith('audio')) {
1147
+ type = 'audio';
1148
+ }
1149
+
1150
+ if (!type) {
1151
+ console.log('โš ๏ธ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ํŒŒ์ผ ํ˜•์‹:', file.type);
1152
+ return;
1153
+ }
1154
 
1155
+ // Blob URL ์ƒ์„ฑ
1156
  const url = URL.createObjectURL(file);
1157
+ console.log('โœ… ํŒŒ์ผ ์ถ”๊ฐ€:', file.name, type);
1158
 
1159
+ // ๋ฏธ๋””์–ด ๊ฐ์ฒด ์ƒ์„ฑ
1160
  const media = {
1161
  id: generateId(),
1162
  name: file.name,
1163
  type: type,
1164
  url: url,
1165
  file: file,
1166
+ duration: type === 'image' ? 5 : 0, // ์ด๋ฏธ์ง€๋Š” ๊ธฐ๋ณธ 5์ดˆ
1167
  thumbnail: type === 'image' ? url : null
1168
  };
1169
 
1170
+ // ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์ถ”๊ฐ€
1171
  mediaLibrary.push(media);
1172
  renderMediaLibrary();
1173
 
1174
+ // ๋น„๋””์˜ค/์˜ค๋””์˜ค ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋กœ๋“œ
1175
  if (type === 'video' || type === 'audio') {
1176
+ loadMediaMetadata(media, type);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1177
  }
1178
  });
1179
  }
1180
 
1181
+ /**
1182
+ * ๋ฏธ๋””์–ด ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋กœ๋“œ
1183
+ */
1184
+ function loadMediaMetadata(media, type) {
1185
+ const el = document.createElement(type);
1186
+ el.src = media.url;
1187
+ el.preload = 'metadata';
1188
+
1189
+ el.onloadedmetadata = function() {
1190
+ media.duration = el.duration;
1191
+ console.log('๐Ÿ“Š ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋กœ๋“œ:', media.name, formatTime(el.duration));
1192
+ renderMediaLibrary();
1193
+
1194
+ // ๋น„๋””์˜ค ์ธ๋„ค์ผ ์ƒ์„ฑ
1195
+ if (type === 'video') {
1196
+ el.currentTime = Math.min(1, el.duration / 2);
1197
+ }
1198
+ };
1199
+
1200
+ el.onseeked = function() {
1201
+ if (type === 'video') {
1202
+ generateVideoThumbnail(el, media);
1203
+ }
1204
+ };
1205
+
1206
+ el.onerror = function(e) {
1207
+ console.error('โŒ ๋ฏธ๋””์–ด ๋กœ๋“œ ์˜ค๋ฅ˜:', media.name, e);
1208
+ };
1209
+ }
1210
+
1211
+ /**
1212
+ * ๋น„๋””์˜ค ์ธ๋„ค์ผ ์ƒ์„ฑ
1213
+ */
1214
+ function generateVideoThumbnail(videoEl, media) {
1215
+ try {
1216
+ const canvas = document.createElement('canvas');
1217
+ canvas.width = 160;
1218
+ canvas.height = 90;
1219
+ const ctx = canvas.getContext('2d');
1220
+ ctx.drawImage(videoEl, 0, 0, 160, 90);
1221
+ media.thumbnail = canvas.toDataURL();
1222
+ renderMediaLibrary();
1223
+ } catch(e) {
1224
+ console.log('โš ๏ธ ์ธ๋„ค์ผ ์ƒ์„ฑ ์‹คํŒจ:', e);
1225
+ }
1226
+ }
1227
+
1228
+ // ========================================
1229
+ // ๋ฏธ๋””์–ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ Œ๋”๋ง
1230
+ // ========================================
1231
  function renderMediaLibrary() {
1232
  const grid = document.getElementById('mediaGrid');
1233
  grid.innerHTML = '';
1234
 
1235
+ // ํƒ€์ž…๋ณ„ ์•„์ด์ฝ˜
1236
+ const typeIcons = {
1237
  video: '<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21"/></svg>',
1238
  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>',
1239
  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>'
 
1245
  item.draggable = true;
1246
  item.dataset.mediaId = media.id;
1247
 
1248
+ // ๋“œ๋ž˜๊ทธ ์ด๋ฒคํŠธ
1249
+ item.ondragstart = function(e) {
1250
+ e.dataTransfer.setData('mediaId', media.id);
1251
+ item.style.opacity = '0.5';
1252
+ };
1253
+
1254
+ item.ondragend = function() {
1255
+ item.style.opacity = '1';
1256
+ };
1257
 
1258
+ // ๋”๋ธ”ํด๋ฆญ์œผ๋กœ ํƒ€์ž„๋ผ์ธ์— ์ถ”๊ฐ€
1259
+ item.ondblclick = function() {
1260
+ addToTimeline(media);
1261
+ };
1262
+
1263
+ // ์ธ๋„ค์ผ HTML
1264
+ let thumbnailHtml = '';
1265
+ if (media.thumbnail) {
1266
+ thumbnailHtml = `<img src="${media.thumbnail}" alt="${media.name}">`;
1267
+ } else {
1268
+ thumbnailHtml = `
1269
+ <div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:#e5e7eb;color:#9ca3af">
1270
+ ${typeIcons[media.type]}
1271
+ </div>
1272
+ `;
1273
+ }
1274
 
1275
  item.innerHTML = `
1276
+ ${thumbnailHtml}
1277
+ <div class="media-item-type">${typeIcons[media.type]}</div>
1278
  ${media.duration > 0 ? `<div class="media-item-duration">${formatTime(media.duration)}</div>` : ''}
1279
+ <div class="media-item-overlay">
1280
+ <span class="media-item-name">${media.name}</span>
1281
+ </div>
1282
  `;
1283
 
1284
  grid.appendChild(item);
1285
  });
1286
  }
1287
 
1288
+ // ========================================
1289
+ // ํƒ€์ž„๋ผ์ธ ๊ด€๋ฆฌ
1290
+ // ========================================
1291
+
1292
+ /**
1293
+ * ๋ฏธ๋””์–ด๋ฅผ ํƒ€์ž„๋ผ์ธ์— ์ถ”๊ฐ€
1294
+ */
1295
  function addToTimeline(media, startTime = null) {
1296
  saveState();
1297
+
1298
+ // ์˜ค๋””์˜ค๋Š” ํŠธ๋ž™ 1, ๋‚˜๋จธ์ง€๋Š” ํŠธ๋ž™ 0
1299
  const track = media.type === 'audio' ? 1 : 0;
1300
  const start = startTime !== null ? startTime : getTrackEndTime(track);
1301
 
1302
+ const clip = {
1303
  id: generateId(),
1304
  mediaId: media.id,
1305
  name: media.name,
 
1312
  trimStart: 0,
1313
  trimEnd: media.duration,
1314
  volume: 1
1315
+ };
1316
+
1317
+ timelineClips.push(clip);
1318
+ console.log('๐ŸŽฌ ํด๋ฆฝ ์ถ”๊ฐ€:', clip.name, 'ํŠธ๋ž™:', track);
1319
 
 
1320
  renderTimeline();
1321
  updateDuration();
1322
  }
1323
 
1324
+ /**
1325
+ * ํŠธ๋ž™์˜ ๋ ์‹œ๊ฐ„ ๊ณ„์‚ฐ
1326
+ */
1327
  function getTrackEndTime(track) {
1328
+ const trackClips = timelineClips.filter(c => c.track === track);
1329
+ if (trackClips.length === 0) return 0;
1330
+ return Math.max(...trackClips.map(c => c.startTime + (c.trimEnd - c.trimStart)));
1331
  }
1332
 
1333
+ /**
1334
+ * ํƒ€์ž„๋ผ์ธ ๋ Œ๋”๋ง
1335
+ */
1336
  function renderTimeline() {
1337
+ // ๋ชจ๋“  ํŠธ๋ž™ ๋‚ด์šฉ ์ดˆ๊ธฐํ™”
1338
+ const tracks = document.querySelectorAll('.track-content');
1339
+ tracks.forEach(track => {
1340
+ track.innerHTML = '';
1341
+ });
1342
 
1343
+ // ํด๋ฆฝ ๋ Œ๋”๋ง
1344
  timelineClips.forEach(clip => {
1345
  const trackEl = document.querySelector(`.timeline-track[data-track="${clip.track}"] .track-content`);
1346
  if (!trackEl) return;
 
1349
  clipEl.className = `timeline-clip ${clip.type}${selectedClipId === clip.id ? ' selected' : ''}`;
1350
  clipEl.dataset.clipId = clip.id;
1351
 
1352
+ // ํด๋ฆฝ ์œ„์น˜ ๋ฐ ํฌ๊ธฐ ๊ณ„์‚ฐ
1353
+ const clipDuration = clip.trimEnd - clip.trimStart;
1354
+ const left = 70 + (clip.startTime * pixelsPerSecond * zoom);
1355
+ const width = Math.max(40, clipDuration * pixelsPerSecond * zoom);
1356
+
1357
+ clipEl.style.left = `${left}px`;
1358
+ clipEl.style.width = `${width}px`;
1359
 
1360
+ // ๋“œ๋ž˜๊ทธ ์ด๋ฒคํŠธ
1361
  clipEl.draggable = true;
1362
+
1363
+ clipEl.onclick = function(e) {
1364
+ e.stopPropagation();
1365
+ selectClip(clip.id);
1366
+ };
1367
+
1368
+ clipEl.oncontextmenu = function(e) {
1369
+ e.preventDefault();
1370
+ selectClip(clip.id);
1371
+ showContextMenu(e.clientX, e.clientY);
1372
+ };
1373
+
1374
+ clipEl.ondragstart = function(e) {
1375
+ e.dataTransfer.setData('clipId', clip.id);
1376
+ e.dataTransfer.setData('offsetX', e.offsetX.toString());
1377
+ };
1378
+
1379
+ // ํด๋ฆฝ ๋‚ด์šฉ
1380
+ let thumbnailHtml = '';
1381
+ if (clip.thumbnail) {
1382
+ thumbnailHtml = `<img class="clip-thumbnail" src="${clip.thumbnail}">`;
1383
+ }
1384
 
1385
  clipEl.innerHTML = `
1386
+ ${thumbnailHtml}
1387
+ <div class="clip-info">
1388
+ <div class="clip-name">${clip.name}</div>
1389
+ <div class="clip-duration">${formatTime(clipDuration)}</div>
1390
+ </div>
1391
  <div class="clip-handles clip-handle-left" onmousedown="startTrim(event, '${clip.id}', 'left')"></div>
1392
  <div class="clip-handles clip-handle-right" onmousedown="startTrim(event, '${clip.id}', 'right')"></div>
1393
  `;
 
1398
  renderRuler();
1399
  }
1400
 
1401
+ /**
1402
+ * ํƒ€์ž„๋ผ์ธ ๋ˆˆ๊ธˆ์ž ๋ Œ๋”๋ง
1403
+ */
1404
  function renderRuler() {
1405
  const ruler = document.getElementById('timelineRuler');
1406
+ const width = Math.max(totalDuration * pixelsPerSecond * zoom + 300, 1000);
1407
+ ruler.style.width = `${width}px`;
1408
 
1409
  let html = '<svg width="100%" height="22" style="position:absolute;left:70px">';
1410
  const step = zoom < 0.7 ? 5 : zoom < 1.5 ? 2 : 1;
1411
+
1412
  for (let i = 0; i <= Math.ceil(totalDuration) + 10; i += step) {
1413
  const x = i * pixelsPerSecond * zoom;
1414
+ html += `<line x1="${x}" y1="17" x2="${x}" y2="22" stroke="#d1d5db" stroke-width="1"/>`;
1415
+ html += `<text x="${x}" y="12" fill="#9ca3af" font-size="9" text-anchor="middle">${formatTime(i)}</text>`;
1416
  }
1417
+
1418
+ html += '</svg>';
1419
+ ruler.innerHTML = html;
1420
+ }
1421
+
1422
+ // ========================================
1423
+ // ๋“œ๋ž˜๊ทธ ์•ค ๋“œ๋กญ
1424
+ // ========================================
1425
+
1426
+ function handleDragOver(event) {
1427
+ event.preventDefault();
1428
+ event.currentTarget.classList.add('drop-highlight');
1429
  }
1430
 
1431
+ function handleDragLeave(event) {
1432
+ event.currentTarget.classList.remove('drop-highlight');
1433
+ }
1434
 
1435
  function handleDrop(event, track) {
1436
  event.preventDefault();
1437
  event.currentTarget.classList.remove('drop-highlight');
1438
 
1439
  const rect = event.currentTarget.getBoundingClientRect();
1440
+ const x = event.clientX - rect.left;
1441
+ const time = Math.max(0, x / (pixelsPerSecond * zoom));
1442
+
1443
  const mediaId = event.dataTransfer.getData('mediaId');
1444
  const clipId = event.dataTransfer.getData('clipId');
1445
  const offsetX = parseFloat(event.dataTransfer.getData('offsetX') || 0);
1446
 
1447
  if (mediaId) {
1448
+ // ๋ฏธ๋””์–ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ ๋“œ๋กญ
1449
  const media = mediaLibrary.find(m => m.id === mediaId);
1450
  if (media) {
1451
  const targetTrack = media.type === 'audio' ? 1 : track;
1452
  addToTimeline(media, time);
1453
+
1454
+ // ๋“œ๋กญ๋œ ํŠธ๋ž™์ด ๋‹ค๋ฅด๋ฉด ์ˆ˜์ •
1455
  if (targetTrack !== track) {
1456
+ const lastClip = timelineClips[timelineClips.length - 1];
1457
+ lastClip.track = targetTrack;
1458
  renderTimeline();
1459
  }
1460
  }
1461
  } else if (clipId) {
1462
+ // ํƒ€์ž„๋ผ์ธ ๋‚ด ํด๋ฆฝ ์ด๋™
1463
  saveState();
1464
  const clip = timelineClips.find(c => c.id === clipId);
1465
  if (clip) {
1466
+ const adjustedTime = Math.max(0, time - (offsetX / (pixelsPerSecond * zoom)));
1467
+ clip.startTime = adjustedTime;
1468
+ // ์˜ค๋””์˜ค ํด๋ฆฝ์€ ์˜ค๋””์˜ค ํŠธ๋ž™์—๋งŒ
1469
  clip.track = clip.type === 'audio' ? 1 : track;
1470
  }
1471
  renderTimeline();
 
1473
  }
1474
  }
1475
 
1476
+ // ========================================
1477
+ // ํด๋ฆฝ ์„ ํƒ ๋ฐ ์†์„ฑ
1478
+ // ========================================
1479
+
1480
+ function selectClip(clipId) {
1481
+ selectedClipId = clipId;
1482
+ renderTimeline();
1483
+ renderProperties();
1484
+ }
1485
 
1486
  function renderProperties() {
1487
  const container = document.getElementById('propertiesContent');
 
1492
  return;
1493
  }
1494
 
1495
+ const clipDuration = clip.trimEnd - clip.trimStart;
1496
+
1497
  container.innerHTML = `
1498
+ <div class="property-group">
1499
+ <div class="property-label">์ด๋ฆ„</div>
1500
+ <input type="text" class="property-input" value="${clip.name}" onchange="updateClipProperty('name', this.value)">
1501
+ </div>
1502
+ <div class="property-group">
1503
+ <div class="property-label">์‹œ์ž‘ ์‹œ๊ฐ„</div>
1504
+ <input type="number" class="property-input" value="${clip.startTime.toFixed(2)}" step="0.1" min="0" onchange="updateClipProperty('startTime', parseFloat(this.value))">
1505
+ </div>
1506
+ <div class="property-group">
1507
+ <div class="property-row">
1508
+ <div>
1509
+ <div class="property-label">ํŠธ๋ฆผ ์‹œ์ž‘</div>
1510
+ <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))">
1511
+ </div>
1512
+ <div>
1513
+ <div class="property-label">ํŠธ๋ฆผ ๋</div>
1514
+ <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))">
1515
+ </div>
1516
+ </div>
1517
+ </div>
1518
+ <div class="property-group">
1519
+ <div class="property-label">๊ธธ์ด</div>
1520
+ <div style="padding:6px 0;font-size:12px;color:#374151">${formatTime(clipDuration)}</div>
1521
+ </div>
1522
+ ${clip.type !== 'image' ? `
1523
+ <div class="property-group">
1524
+ <div class="property-label">๋ณผ๋ฅจ (${Math.round(clip.volume * 100)}%)</div>
1525
+ <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))">
1526
+ </div>
1527
+ ` : ''}
1528
  `;
1529
  }
1530
 
1531
  function updateClipProperty(prop, value) {
1532
  saveState();
1533
+ timelineClips = timelineClips.map(c =>
1534
+ c.id === selectedClipId ? { ...c, [prop]: value } : c
1535
+ );
1536
  renderTimeline();
1537
  updateDuration();
1538
  renderProperties();
1539
  }
1540
 
1541
+ // ========================================
1542
+ // ํด๋ฆฝ ํŽธ์ง‘ ๊ธฐ๋Šฅ
1543
+ // ========================================
1544
+
1545
+ /**
1546
+ * ์„ ํƒ๋œ ํด๋ฆฝ ์ž๋ฅด๊ธฐ (์ค‘๊ฐ„ ์ง€์ ์—์„œ)
1547
+ */
1548
  function splitSelectedClip() {
1549
  if (!selectedClipId) return;
1550
+
1551
  const clip = timelineClips.find(c => c.id === selectedClipId);
1552
  if (!clip) return;
1553
 
1554
  saveState();
1555
+
1556
+ const clipDuration = clip.trimEnd - clip.trimStart;
1557
+ const splitPoint = clipDuration / 2;
1558
+
1559
+ // ์ฒซ ๋ฒˆ์งธ ํด๋ฆฝ (์•ž๋ถ€๋ถ„)
1560
+ const clip1 = { ...clip, trimEnd: clip.trimStart + splitPoint };
1561
+
1562
+ // ๋‘ ๋ฒˆ์งธ ํด๋ฆฝ (๋’ท๋ถ€๋ถ„)
1563
+ const clip2 = {
1564
+ ...clip,
1565
+ id: generateId(),
1566
+ startTime: clip.startTime + splitPoint,
1567
+ trimStart: clip.trimStart + splitPoint
1568
+ };
1569
 
1570
  timelineClips = timelineClips.map(c => c.id === clip.id ? clip1 : c);
1571
  timelineClips.push(clip2);
1572
+
1573
  renderTimeline();
1574
  hideContextMenu();
1575
  }
1576
 
1577
+ /**
1578
+ * ์„ ํƒ๋œ ํด๋ฆฝ ๋ณต์ œ
1579
+ */
1580
  function duplicateSelectedClip() {
1581
  if (!selectedClipId) return;
1582
+
1583
  const clip = timelineClips.find(c => c.id === selectedClipId);
1584
  if (!clip) return;
1585
 
1586
  saveState();
1587
+
1588
+ const clipDuration = clip.trimEnd - clip.trimStart;
1589
+ const newClip = {
1590
+ ...clip,
1591
+ id: generateId(),
1592
+ startTime: clip.startTime + clipDuration
1593
+ };
1594
+
1595
+ timelineClips.push(newClip);
1596
  renderTimeline();
1597
  updateDuration();
1598
  hideContextMenu();
1599
  }
1600
 
1601
+ /**
1602
+ * ์„ ํƒ๋œ ํด๋ฆฝ ์‚ญ์ œ
1603
+ */
1604
  function deleteSelectedClip() {
1605
  if (!selectedClipId) return;
1606
+
1607
  saveState();
1608
  timelineClips = timelineClips.filter(c => c.id !== selectedClipId);
1609
  selectedClipId = null;
1610
+
1611
  renderTimeline();
1612
  renderProperties();
1613
  updateDuration();
1614
  hideContextMenu();
1615
  }
1616
 
1617
+ // ========================================
1618
+ // ํŠธ๋ฆผ ํ•ธ๋“ค
1619
+ // ========================================
1620
+
1621
  function startTrim(event, clipId, side) {
1622
  event.stopPropagation();
1623
  event.preventDefault();
1624
+
1625
  const clip = timelineClips.find(c => c.id === clipId);
1626
  if (!clip) return;
1627
+
1628
  saveState();
1629
+
1630
+ trimData = {
1631
+ clipId: clipId,
1632
+ side: side,
1633
+ startX: event.clientX,
1634
+ originalTrimStart: clip.trimStart,
1635
+ originalTrimEnd: clip.trimEnd,
1636
+ originalStartTime: clip.startTime
1637
+ };
1638
+
1639
  document.addEventListener('mousemove', handleTrim);
1640
  document.addEventListener('mouseup', endTrim);
1641
  }
1642
 
1643
  function handleTrim(event) {
1644
  if (!trimData) return;
1645
+
1646
  const clip = timelineClips.find(c => c.id === trimData.clipId);
1647
  if (!clip) return;
1648
 
1649
+ const deltaX = event.clientX - trimData.startX;
1650
+ const deltaTime = deltaX / (pixelsPerSecond * zoom);
1651
+
1652
  if (trimData.side === 'left') {
1653
+ // ์™ผ์ชฝ ํ•ธ๋“ค: ์‹œ์ž‘ ์ง€์  ์กฐ์ •
1654
  const newTrimStart = Math.max(0, Math.min(clip.trimEnd - 0.1, trimData.originalTrimStart + deltaTime));
1655
+ const trimDelta = newTrimStart - trimData.originalTrimStart;
1656
  clip.trimStart = newTrimStart;
1657
+ clip.startTime = trimData.originalStartTime + trimDelta;
1658
  } else {
1659
+ // ์˜ค๋ฅธ์ชฝ ํ•ธ๋“ค: ๋ ์ง€์  ์กฐ์ •
1660
  clip.trimEnd = Math.max(clip.trimStart + 0.1, Math.min(clip.duration, trimData.originalTrimEnd + deltaTime));
1661
  }
1662
+
1663
  renderTimeline();
1664
  updateDuration();
1665
  }
 
1670
  document.removeEventListener('mouseup', endTrim);
1671
  }
1672
 
1673
+ // ========================================
1674
+ // ์žฌ์ƒ ์ปจํŠธ๋กค
1675
+ // ========================================
1676
+
1677
  function updateDuration() {
1678
+ if (timelineClips.length === 0) {
1679
+ totalDuration = 0;
1680
+ } else {
1681
+ totalDuration = Math.max(...timelineClips.map(c => c.startTime + (c.trimEnd - c.trimStart)));
1682
+ }
1683
  document.getElementById('durationDisplay').textContent = formatTime(totalDuration);
1684
  }
1685
 
1686
  function togglePlay() {
1687
  isPlaying = !isPlaying;
1688
  const icon = document.getElementById('playIcon');
1689
+
1690
+ if (isPlaying) {
1691
+ icon.innerHTML = '<rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/>';
1692
+ startPlayback();
1693
+ } else {
1694
+ icon.innerHTML = '<polygon points="5 3 19 12 5 21 5 3"/>';
1695
+ stopPlayback();
1696
+ }
1697
  }
1698
 
1699
  function startPlayback() {
1700
  let lastTime = performance.now();
1701
+
1702
  function animate(now) {
1703
  if (!isPlaying) return;
1704
+
1705
+ const delta = (now - lastTime) / 1000;
1706
  lastTime = now;
1707
+
1708
+ currentTime += delta;
1709
+
1710
+ // ๋์— ๋„๋‹ฌํ•˜๋ฉด ์ฒ˜์Œ์œผ๋กœ
1711
+ if (currentTime >= totalDuration) {
1712
+ currentTime = 0;
1713
+ if (totalDuration === 0) {
1714
+ isPlaying = false;
1715
+ document.getElementById('playIcon').innerHTML = '<polygon points="5 3 19 12 5 21 5 3"/>';
1716
+ return;
1717
+ }
1718
+ }
1719
+
1720
  updatePlayhead();
1721
  updatePreview();
1722
+
1723
  animationId = requestAnimationFrame(animate);
1724
  }
1725
+
1726
  animationId = requestAnimationFrame(animate);
1727
  }
1728
 
1729
  function stopPlayback() {
1730
+ if (animationId) {
1731
+ cancelAnimationFrame(animationId);
1732
+ animationId = null;
1733
+ }
1734
+
1735
+ // ๋น„๋””์˜ค ์ผ์‹œ์ •์ง€
1736
  const video = document.querySelector('#previewContainer video');
1737
+ if (video && !video.paused) {
1738
+ video.pause();
1739
+ }
1740
  }
1741
 
1742
  function updatePlayhead() {
1743
+ const playhead = document.getElementById('playhead');
1744
+ const left = 70 + (currentTime * pixelsPerSecond * zoom);
1745
+ playhead.style.left = `${left}px`;
1746
  document.getElementById('currentTimeDisplay').textContent = formatTime(currentTime);
1747
  }
1748
 
1749
  function updatePreview() {
1750
  const container = document.getElementById('previewContainer');
 
 
1751
 
1752
+ // ํ˜„์žฌ ์‹œ๊ฐ„์— ์žฌ์ƒ ์ค‘์ธ ํด๋ฆฝ ์ฐพ๊ธฐ
1753
+ const currentClips = timelineClips.filter(clip => {
1754
+ const clipEnd = clip.startTime + (clip.trimEnd - clip.trimStart);
1755
+ return currentTime >= clip.startTime && currentTime < clipEnd;
1756
+ });
1757
+
1758
+ // ๋น„๋””์˜ค/์ด๋ฏธ์ง€ ํด๋ฆฝ ์ฐพ๊ธฐ
1759
+ const visualClip = currentClips.find(c => c.type === 'video' || c.type === 'image');
1760
+
1761
+ if (visualClip) {
1762
+ const clipTime = currentTime - visualClip.startTime + visualClip.trimStart;
1763
+
1764
+ if (visualClip.type === 'image') {
1765
+ // ์ด๋ฏธ์ง€ ํ‘œ์‹œ
1766
+ if (!container.querySelector(`img[data-clip-id="${visualClip.id}"]`)) {
1767
+ container.innerHTML = `<img src="${visualClip.url}" data-clip-id="${visualClip.id}">`;
1768
+ }
1769
+ } else if (visualClip.type === 'video') {
1770
+ // ๋น„๋””์˜ค ํ‘œ์‹œ
1771
+ let video = container.querySelector(`video[data-clip-id="${visualClip.id}"]`);
1772
+ if (!video) {
1773
+ container.innerHTML = `<video src="${visualClip.url}" data-clip-id="${visualClip.id}" ${isMuted ? 'muted' : ''}></video>`;
1774
+ video = container.querySelector('video');
1775
+ }
1776
+
1777
+ // ์‹œ๊ฐ„ ๋™๊ธฐํ™”
1778
+ if (Math.abs(video.currentTime - clipTime) > 0.2) {
1779
+ video.currentTime = clipTime;
1780
+ }
1781
+
1782
+ // ์žฌ์ƒ/์ผ์‹œ์ •์ง€
1783
+ if (isPlaying && video.paused) {
1784
+ video.play().catch(() => {});
1785
+ } else if (!isPlaying && !video.paused) {
1786
+ video.pause();
1787
+ }
1788
+
1789
+ video.volume = isMuted ? 0 : visualClip.volume;
1790
  video.muted = isMuted;
1791
  }
1792
+ } else if (!currentClips.some(c => c.type === 'video' || c.type === 'image')) {
1793
+ // ์‹œ๊ฐ์  ํด๋ฆฝ์ด ์—†์„ ๋•Œ
1794
+ if (!container.querySelector('.preview-placeholder')) {
1795
+ container.innerHTML = `
1796
+ <div class="preview-placeholder">
1797
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1">
1798
+ <rect x="2" y="2" width="20" height="20" rx="2"/>
1799
+ <polygon points="10 8 16 12 10 16 10 8"/>
1800
+ </svg>
1801
+ <p>${currentClips.length > 0 ? '๐ŸŽต ์˜ค๋””์˜ค ์žฌ์ƒ ์ค‘' : 'ํƒ€์ž„๋ผ์ธ์— ๋ฏธ๋””์–ด๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”'}</p>
1802
+ </div>
1803
+ `;
1804
+ }
1805
  }
1806
  }
1807
 
1808
+ function skipToStart() {
1809
+ currentTime = 0;
1810
+ updatePlayhead();
1811
+ updatePreview();
1812
+ }
1813
+
1814
+ function skipToEnd() {
1815
+ currentTime = totalDuration;
1816
+ updatePlayhead();
1817
+ updatePreview();
1818
+ }
1819
+
1820
+ function skipBackward() {
1821
+ currentTime = Math.max(0, currentTime - 5);
1822
+ updatePlayhead();
1823
+ updatePreview();
1824
+ }
1825
+
1826
+ function skipForward() {
1827
+ currentTime = Math.min(totalDuration, currentTime + 5);
1828
+ updatePlayhead();
1829
+ updatePreview();
1830
+ }
1831
 
1832
  function toggleMute() {
1833
  isMuted = !isMuted;
1834
+ const icon = document.getElementById('volumeIcon');
1835
+
1836
+ if (isMuted) {
1837
+ 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"/>';
1838
+ } else {
1839
+ 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"/>';
1840
+ }
1841
+
1842
  const video = document.querySelector('#previewContainer video');
1843
+ if (video) {
1844
+ video.muted = isMuted;
1845
+ }
1846
+ }
1847
+
1848
+ function setZoom(value) {
1849
+ zoom = parseFloat(value);
1850
+ renderTimeline();
1851
+ updatePlayhead();
1852
  }
1853
 
1854
+ // ========================================
1855
+ // ์ปจํ…์ŠคํŠธ ๋ฉ”๋‰ด
1856
+ // ========================================
1857
+
1858
+ function showContextMenu(x, y) {
1859
+ const menu = document.getElementById('contextMenu');
1860
+ menu.style.display = 'block';
1861
+ menu.style.left = `${x}px`;
1862
+ menu.style.top = `${y}px`;
1863
+ }
1864
 
1865
+ function hideContextMenu() {
1866
+ document.getElementById('contextMenu').style.display = 'none';
1867
+ }
1868
 
1869
+ // ๋‹ค๋ฅธ ๊ณณ ํด๋ฆญ์‹œ ์ปจํ…์ŠคํŠธ ๋ฉ”๋‰ด ๋‹ซ๊ธฐ
1870
+ document.addEventListener('click', function(e) {
1871
+ if (!e.target.closest('.context-menu')) {
1872
+ hideContextMenu();
1873
+ }
1874
+ });
1875
+
1876
+ // ========================================
1877
+ // ํƒ€์ž„๋ผ์ธ ํด๋ฆญ์œผ๋กœ ์žฌ์ƒ ์œ„์น˜ ๋ณ€๊ฒฝ
1878
+ // ========================================
1879
  document.getElementById('timelineContainer').addEventListener('click', function(e) {
1880
  if (e.target.closest('.timeline-clip')) return;
1881
+
1882
+ const rect = this.getBoundingClientRect();
1883
+ const x = e.clientX - rect.left - 70 + this.scrollLeft;
1884
+ currentTime = Math.max(0, Math.min(totalDuration, x / (pixelsPerSecond * zoom)));
1885
  updatePlayhead();
1886
  updatePreview();
1887
  });
1888
 
1889
+ // ========================================
1890
+ // ๋‚ด๋ณด๋‚ด๊ธฐ
1891
+ // ========================================
1892
  async function exportVideo() {
1893
+ if (timelineClips.length === 0) {
1894
+ alert('ํƒ€์ž„๋ผ์ธ์— ํด๋ฆฝ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.');
1895
+ return;
1896
+ }
1897
+
1898
  document.getElementById('exportModal').style.display = 'flex';
1899
+ document.getElementById('exportProgress').style.width = '0%';
1900
+ document.getElementById('exportStatus').textContent = '์˜์ƒ์„ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค...';
1901
+
1902
+ // ์ง„ํ–‰๋ฅ  ์‹œ๋ฎฌ๋ ˆ์ด์…˜
1903
  for (let i = 0; i <= 100; i += 2) {
1904
  await new Promise(r => setTimeout(r, 50));
1905
  document.getElementById('exportProgress').style.width = `${i}%`;
1906
+
1907
+ if (i === 30) {
1908
+ document.getElementById('exportStatus').textContent = 'ํด๋ฆฝ ๋ณ‘ํ•ฉ ์ค‘...';
1909
+ }
1910
+ if (i === 60) {
1911
+ document.getElementById('exportStatus').textContent = '์˜ค๋””์˜ค ์ฒ˜๋ฆฌ ์ค‘...';
1912
+ }
1913
+ if (i === 90) {
1914
+ document.getElementById('exportStatus').textContent = '์ตœ์ข… ๋ Œ๋”๋ง ์ค‘...';
1915
+ }
1916
  }
1917
+
1918
  document.getElementById('exportStatus').textContent = 'โœ… ์™„๋ฃŒ!';
1919
  document.getElementById('cancelExportBtn').textContent = '๋‹ซ๊ธฐ';
1920
  }
1921
 
1922
+ function cancelExport() {
1923
+ document.getElementById('exportModal').style.display = 'none';
1924
+ document.getElementById('cancelExportBtn').textContent = '์ทจ์†Œ';
1925
+ }
1926
 
1927
+ // ========================================
1928
+ // ํ‚ค๋ณด๋“œ ๋‹จ์ถ•ํ‚ค
1929
+ // ========================================
1930
  document.addEventListener('keydown', function(e) {
1931
+ // ์ž…๋ ฅ ํ•„๋“œ์—์„œ๋Š” ๋‹จ์ถ•ํ‚ค ๋น„ํ™œ์„ฑํ™”
1932
  if (e.target.tagName === 'INPUT') return;
1933
+
1934
  switch(e.code) {
1935
+ case 'Space':
1936
+ e.preventDefault();
1937
+ togglePlay();
1938
+ break;
1939
+
1940
+ case 'Delete':
1941
+ case 'Backspace':
1942
+ e.preventDefault();
1943
+ if (selectedClipId) deleteSelectedClip();
1944
+ break;
1945
+
1946
+ case 'KeyD':
1947
+ if (e.ctrlKey || e.metaKey) {
1948
+ e.preventDefault();
1949
+ if (selectedClipId) duplicateSelectedClip();
1950
+ }
1951
+ break;
1952
+
1953
+ case 'KeyZ':
1954
+ if (e.ctrlKey || e.metaKey) {
1955
+ e.preventDefault();
1956
+ undoAction();
1957
+ }
1958
+ break;
1959
+
1960
+ case 'ArrowLeft':
1961
+ e.preventDefault();
1962
+ currentTime = Math.max(0, currentTime - (e.shiftKey ? 1 : 0.1));
1963
+ updatePlayhead();
1964
+ updatePreview();
1965
+ break;
1966
+
1967
+ case 'ArrowRight':
1968
+ e.preventDefault();
1969
+ currentTime = Math.min(totalDuration, currentTime + (e.shiftKey ? 1 : 0.1));
1970
+ updatePlayhead();
1971
+ updatePreview();
1972
+ break;
1973
  }
1974
  });
1975
  </script>
 
1979
 
1980
 
1981
  def create_interface():
1982
+ """Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ"""
1983
+
1984
  with gr.Blocks(title="Simple Video Editor") as demo:
1985
  gr.HTML(EDITOR_HTML)
1986
+
1987
  return demo
1988
 
1989
 
1990
  if __name__ == "__main__":
1991
  demo = create_interface()
1992
+ demo.launch(
1993
+ server_name="0.0.0.0",
1994
+ server_port=7860,
1995
+ share=False
1996
+ )