@lunagerm-studio/video-cut-skill 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +13 -2
  2. package/package.json +12 -4
  3. package/skills/ai-video-opening/SKILL.md +62 -0
  4. package/skills/ai-video-opening/references/export-and-validation.md +9 -0
  5. package/skills/ai-video-opening/references/motion-and-layout.md +7 -0
  6. package/skills/ai-video-opening/references/series-cases.md +7 -0
  7. package/skills/blue-white-ui-motion/SKILL.md +30 -0
  8. package/skills/blue-white-ui-motion/agents/openai.yaml +2 -0
  9. package/skills/blue-white-ui-motion/references/review.md +25 -0
  10. package/skills/chengfeng-videocut-skills/LICENSE +201 -0
  11. package/skills/chengfeng-videocut-skills/NOTICE.md +27 -0
  12. package/skills/chengfeng-videocut-skills/README.md +265 -0
  13. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/SKILL.md +37 -0
  14. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/agents/openai.yaml +2 -0
  15. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/cut_video.sh +182 -0
  16. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/detect_en_stutter.js +49 -0
  17. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_review.js +1484 -0
  18. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_srt_for_video.sh +75 -0
  19. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_subtitles.js +141 -0
  20. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/review_server.js +381 -0
  21. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/volcengine_transcribe.sh +224 -0
  22. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/watch_cut_done.js +86 -0
  23. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/1-/346/240/270/345/277/203/345/216/237/345/210/231.md +56 -0
  24. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/10-/345/210/240/351/231/244/351/243/216/351/231/251/345/210/206/345/261/202.md +44 -0
  25. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/11-/345/217/243/346/222/255/347/250/277/345/257/271/351/275/220.md +40 -0
  26. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/2-/350/257/255/346/260/224/350/257/215/346/243/200/346/265/213.md +30 -0
  27. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/3-/351/235/231/351/237/263/346/256/265/345/244/204/347/220/206.md +56 -0
  28. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/4-/351/207/215/345/244/215/346/243/200/346/265/213.md +77 -0
  29. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/5-/345/215/241/351/241/277/350/257/215.md +48 -0
  30. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/7-/350/277/236/347/273/255/350/257/255/346/260/224/350/257/215.md +32 -0
  31. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/9-/346/256/213/345/217/245/346/243/200/346/265/213.md +79 -0
  32. package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/README.md +35 -0
  33. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/SKILL.md +32 -0
  34. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/agents/openai.yaml +2 -0
  35. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/references/artifact-contracts.md +168 -0
  36. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/animation_style.cjs +53 -0
  37. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/export_final_video.cjs +200 -0
  38. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/serve_range_preview.cjs +128 -0
  39. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/user_config.cjs +80 -0
  40. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/write_render_mode.cjs +149 -0
  41. package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207//347/224/250/346/210/267/351/205/215/347/275/256/default.json +4 -0
  42. package/skills/chengfeng-videocut-skills//350/207/252/350/277/233/345/214/226/README.md +23 -0
  43. package/skills/chengfeng-videocut-skills//350/207/252/350/277/233/345/214/226/SKILL.md +126 -0
  44. package/skills/continuous-collage-motion/SKILL.md +30 -0
  45. package/skills/continuous-collage-motion/agents/openai.yaml +4 -0
  46. package/skills/continuous-collage-motion/references/reference-motion.md +32 -0
  47. package/skills/continuous-collage-motion/references/shot-plan.md +31 -0
  48. package/skills/continuous-collage-motion/references/style-check.md +17 -0
  49. package/skills/table-video/LICENSES/ATTRIBUTION.md +31 -0
  50. package/skills/table-video/LICENSES/CC-BY-4.0.txt +396 -0
  51. package/skills/table-video/LICENSES/MIT.txt +21 -0
  52. package/skills/table-video/SKILL.md +32 -0
  53. package/skills/table-video/SOURCES.md +61 -0
  54. package/skills/table-video/agents/openai.yaml +2 -0
  55. package/skills/table-video/references/complete-motion.md +97 -0
  56. package/skills/table-video/references/examples/01_/344/270/244/346/256/265/346/274/224/347/244/272.md +73 -0
  57. package/skills/table-video/references/examples/02_/347/224/237/345/233/276/347/224/237/350/247/206/351/242/221/346/217/220/347/244/272/350/257/215/347/244/272/344/276/213.md +50 -0
  58. package/skills/table-video/references/examples/03_DESIGN/345/241/253/345/206/231/347/244/272/344/276/213.md +333 -0
  59. package/skills/table-video/references/examples/04_/350/277/236/347/273/255MG/346/255/243/345/217/215/350/277/207/347/250/213.md +101 -0
  60. package/skills/table-video/references/examples/05_/345/256/214/346/225/264/350/277/207/347/250/213/346/272/220/347/240/201.md +55 -0
  61. package/skills/table-video/references/examples/05_/346/205/242/351/225/234/345/244/264/344/270/216/345/220/214/346/236/204/345/233/276/345/233/236/345/275/222.md +35 -0
  62. package/skills/table-video/references/experience//345/255/227/345/271/225/344/270/216/345/260/201/351/235/242.md +30 -0
  63. package/skills/table-video/references/experience//345/275/225/345/261/217/345/211/252/350/276/221.md +31 -0
  64. package/skills/table-video/references/experience//346/211/213/345/212/250/347/224/237/345/233/276/347/224/237/350/247/206/351/242/221.md +53 -0
  65. package/skills/table-video/references/experience//350/247/206/350/247/211/345/217/231/344/272/213/344/270/216/350/277/236/347/273/255MG.md +102 -0
  66. package/skills/table-video/references/experience//351/225/234/345/244/264/346/216/250/350/277/233/344/270/216/350/275/254/345/234/272.md +178 -0
  67. package/skills/table-video/references/intake.md +84 -0
  68. package/skills/table-video/references/library.md +26 -0
  69. package/skills/table-video/references/motion-check-method.md +147 -0
  70. package/skills/table-video/references/planning.md +62 -0
  71. package/skills/table-video/references/production.md +70 -0
  72. package/skills/table-video/references/project-rules.md +26 -0
  73. package/skills/table-video/references/review-and-repair.md +64 -0
  74. package/skills/table-video/references/self-diagnosis.md +46 -0
  75. package/skills/table-video/references/sop/01_/345/277/253/351/200/237/345/274/200/345/247/213.md +55 -0
  76. package/skills/table-video/references/sop/02_/345/210/266/344/275/234SOP.md +77 -0
  77. package/skills/table-video/references/sop/03_/347/233/256/345/275/225/344/270/216/345/271/266/350/241/214/345/215/217/344/275/234.md +72 -0
  78. package/skills/table-video/references/sop/04_/351/252/214/346/224/266/344/270/216/350/277/224/344/277/256.md +146 -0
  79. package/skills/table-video/references/sop/05_/346/226/207/346/241/210/346/243/200/346/237/245_/345/217/257/351/200/211.md +55 -0
  80. package/skills/table-video/references/sop/06_/351/237/263/346/225/210/344/270/216/351/205/215/344/271/220_/345/217/257/351/200/211.md +138 -0
  81. package/skills/table-video/references/sop/07_/345/267/245/345/205/267/344/270/216/347/216/257/345/242/203.md +52 -0
  82. package/skills/table-video/references/sop/08_/346/235/245/346/272/220/344/270/216/350/256/270/345/217/257.md +36 -0
  83. package/skills/table-video/references/sop/09_DESIGN/345/273/272/347/253/213/344/270/216/346/240/241/351/252/214.md +52 -0
  84. package/skills/table-video/references/state-contract.md +267 -0
  85. package/skills/table-video/references/style-and-motion.md +163 -0
  86. package/skills/table-video/schemas/request.schema.json +44 -0
  87. package/skills/table-video/schemas/state.schema.json +140 -0
  88. package/skills/table-video/scripts/cli.mjs +35 -0
  89. package/skills/table-video/scripts/core.mjs +977 -0
  90. package/skills/table-video/scripts/gain-proof.mjs +48 -0
  91. package/skills/table-video/scripts/init-project.mjs +7 -0
  92. package/skills/table-video/scripts/motion-audit.mjs +589 -0
  93. package/skills/table-video/scripts/motion-check.mjs +345 -0
  94. package/skills/table-video/scripts/motion-gates.mjs +997 -0
  95. package/skills/table-video/scripts/motion-observation.cjs +204 -0
  96. package/skills/table-video/scripts/preflight.mjs +24 -0
  97. package/skills/table-video/scripts/process-locate.mjs +57 -0
  98. package/skills/table-video/scripts/render-motion-example.mjs +143 -0
  99. package/skills/table-video/scripts/save-reference-image.mjs +249 -0
  100. package/skills/table-video/scripts/schema.mjs +71 -0
  101. package/skills/table-video/scripts/stillness.mjs +386 -0
  102. package/skills/table-video/scripts/storage.mjs +328 -0
  103. package/skills/table-video/scripts/workflow.mjs +24 -0
  104. package/skills/talking-head-motion-workflow/SKILL.md +36 -0
  105. package/skills/talking-head-motion-workflow/agents/openai.yaml +4 -0
  106. package/skills/talking-head-motion-workflow/references/cinematic-motion-and-sync.md +72 -0
  107. package/skills/talking-head-motion-workflow/references/classic-ui.md +11 -0
  108. package/skills/talking-head-motion-workflow/references/history-coverage.md +50 -0
  109. package/skills/talking-head-motion-workflow/references/layered-assets-and-characters.md +39 -0
  110. package/skills/talking-head-motion-workflow/references/layout-references.md +41 -0
  111. package/skills/talking-head-motion-workflow/references/lens-shot-selection.md +138 -0
  112. package/skills/talking-head-motion-workflow/references/live-interface-motion.md +69 -0
  113. package/skills/talking-head-motion-workflow/references/motion-recipes.md +40 -0
  114. package/skills/talking-head-motion-workflow/references/mouse-meter2-case.md +113 -0
  115. package/skills/talking-head-motion-workflow/references/pop-collage.md +61 -0
  116. package/skills/talking-head-motion-workflow/references/portable-production.md +32 -0
  117. package/skills/talking-head-motion-workflow/references/production-requirements.md +85 -0
  118. package/skills/talking-head-motion-workflow/references/reference-library.md +41 -0
  119. package/skills/talking-head-motion-workflow/references/safe-areas-and-sound.md +47 -0
  120. package/skills/talking-head-motion-workflow/references/scene-illustrations.md +19 -0
  121. package/skills/talking-head-motion-workflow/references/sfx-presets.md +57 -0
  122. package/skills/talking-head-motion-workflow/references/style-13-github-production.md +33 -0
  123. package/skills/talking-head-motion-workflow/references/style-13-scene-performance.md +76 -0
  124. package/skills/talking-head-motion-workflow/references/style-presets.md +111 -0
  125. package/skills/talking-head-motion-workflow/references/table-video-spatial-mg.md +36 -0
  126. package/skills/talking-head-motion-workflow/scripts/extract_docx.py +19 -0
  127. package/skills/talking-head-motion-workflow/scripts/generate_foley.py +93 -0
  128. package/skills/talking-head-motion-workflow/scripts/render_sfx.py +135 -0
  129. package/skills/video-production-review/SKILL.md +30 -0
  130. package/skills/video-production-review/agents/openai.yaml +2 -0
  131. package/skills/video-production-review/references/episode-review-desk.md +30 -0
  132. package/skills/video-production-review/references/motion-adjustment-review.md +21 -0
  133. package/skills/video-production-workflow/SKILL.md +78 -0
  134. package/skills/video-production-workflow/agents/openai.yaml +2 -0
  135. package/skills/video-production-workflow/references/table-video-ep09.md +17 -0
  136. package/skills/video-production-workflow/scripts/check_motion_project.py +83 -0
  137. package/skills/video-reference-analysis/SKILL.md +32 -0
  138. package/skills/video-reference-analysis/agents/openai.yaml +2 -0
  139. package/skills/video-reference-analysis/references/case-format.md +95 -0
  140. package/skills/video-reference-analysis/references/production-method.md +21 -0
  141. package/skills/video-reference-analysis/scripts/library.py +371 -0
  142. package/skills/video-resource-access/SKILL.md +39 -0
  143. package/skills/video-resource-access/online.enabled +1 -0
  144. package/skills/video-resource-access/scripts/asset_client.py +161 -0
  145. package/skills/video-resource-access/scripts/remote_library.py +50 -0
  146. package//345/256/211/350/243/205/350/257/264/346/230/216.txt +5 -0
@@ -0,0 +1,1484 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 生成审核网页(视频版本)
4
+ *
5
+ * 用法: node generate_review.js <subtitles_words.json> [auto_selected.json] [video_file]
6
+ * 输出: review.html, video.mp4(符号链接到当前目录)
7
+ */
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const { execFileSync } = require('child_process');
12
+
13
+ const subtitlesFile = process.argv[2] || 'subtitles_words.json';
14
+ const autoSelectedFile = process.argv[3] || 'auto_selected.json';
15
+ const videoFile = process.argv[4] || 'video.mp4';
16
+
17
+ // 创建视频文件的符号链接到当前目录(避免复制大文件)
18
+ const videoBaseName = 'video.mp4';
19
+ if (videoFile !== videoBaseName && fs.existsSync(videoFile)) {
20
+ const absVideoPath = path.resolve(videoFile);
21
+ if (fs.existsSync(videoBaseName)) fs.unlinkSync(videoBaseName);
22
+ fs.symlinkSync(absVideoPath, videoBaseName);
23
+ console.log('📁 已链接视频到当前目录:', videoBaseName, '→', absVideoPath);
24
+ }
25
+
26
+ if (!fs.existsSync(subtitlesFile)) {
27
+ console.error('❌ 找不到字幕文件:', subtitlesFile);
28
+ process.exit(1);
29
+ }
30
+
31
+ const words = JSON.parse(fs.readFileSync(subtitlesFile, 'utf8'));
32
+ let autoSelected = [];
33
+
34
+ if (fs.existsSync(autoSelectedFile)) {
35
+ autoSelected = JSON.parse(fs.readFileSync(autoSelectedFile, 'utf8'));
36
+ console.log('AI 预选:', autoSelected.length, '个元素');
37
+ }
38
+
39
+ function readVideoAspectRatio(file) {
40
+ const target = fs.existsSync(file) ? file : videoBaseName;
41
+ try {
42
+ const output = execFileSync('ffprobe', [
43
+ '-v', 'error',
44
+ '-select_streams', 'v:0',
45
+ '-show_entries', 'stream=width,height',
46
+ '-of', 'csv=p=0',
47
+ target,
48
+ ], { encoding: 'utf8' }).trim();
49
+ const [width, height] = output.split(',').map(Number);
50
+ if (width > 0 && height > 0) return `${width} / ${height}`;
51
+ } catch (e) {
52
+ console.warn('⚠️ 未能读取视频比例,使用默认竖屏比例 9:16');
53
+ }
54
+ return '9 / 16';
55
+ }
56
+
57
+ const videoAspectRatio = readVideoAspectRatio(videoFile);
58
+
59
+ const html = `<!DOCTYPE html>
60
+ <html lang="zh-CN">
61
+ <head>
62
+ <meta charset="UTF-8">
63
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
64
+ <title>剪口播 · 审核稿</title>
65
+ <style>
66
+ :root {
67
+ --bg-canvas: #f7f6f3;
68
+ --bg-surface: #ffffff;
69
+ --bg-muted: #f4f3f0;
70
+ --bg-subtle: #fafaf8;
71
+ --border: rgba(15, 15, 15, 0.08);
72
+ --divider: rgba(15, 15, 15, 0.055);
73
+ --text: #191918;
74
+ --text-muted: #6b6b67;
75
+ --text-faint: #9a9a95;
76
+ --accent: #0f7b6c;
77
+ --accent-soft: #e6f2ef;
78
+ --accent-text: #0a5d50;
79
+ --deleted-bg: #fbe9e7;
80
+ --deleted-fg: #b43c2a;
81
+ --highlight-bg: #fef0c7;
82
+ --highlight-fg: #7c5a10;
83
+ --font-body: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
84
+ --font-mono: "SF Mono", "JetBrains Mono", "Menlo", monospace;
85
+ --sidebar-w: clamp(460px, 42vw, 600px);
86
+ --header-h: 44px;
87
+ }
88
+
89
+ * { box-sizing: border-box; margin: 0; padding: 0; }
90
+
91
+ body {
92
+ font-family: var(--font-body);
93
+ background: var(--bg-canvas);
94
+ color: var(--text);
95
+ height: 100vh;
96
+ display: flex;
97
+ flex-direction: column;
98
+ overflow: hidden;
99
+ -webkit-font-smoothing: antialiased;
100
+ }
101
+
102
+ /* ─── Header ─── */
103
+ .header {
104
+ height: var(--header-h);
105
+ background: var(--bg-surface);
106
+ border-bottom: 1px solid var(--border);
107
+ display: flex;
108
+ align-items: center;
109
+ justify-content: space-between;
110
+ padding: 0 16px;
111
+ flex-shrink: 0;
112
+ z-index: 10;
113
+ }
114
+ .header-left {
115
+ display: flex;
116
+ align-items: center;
117
+ gap: 10px;
118
+ font-size: 14px;
119
+ font-weight: 500;
120
+ color: var(--text);
121
+ min-width: 0;
122
+ }
123
+ .header-left .logo {
124
+ font-size: 15px;
125
+ display: flex;
126
+ align-items: center;
127
+ gap: 6px;
128
+ white-space: nowrap;
129
+ }
130
+ .header-left .logo .icon { font-size: 16px; }
131
+ .header-left .badge {
132
+ font-size: 11px;
133
+ font-weight: 500;
134
+ background: var(--accent-soft);
135
+ color: var(--accent-text);
136
+ padding: 2px 8px;
137
+ border-radius: 10px;
138
+ }
139
+ .header-right {
140
+ display: flex;
141
+ align-items: center;
142
+ gap: 6px;
143
+ }
144
+ .header-btn {
145
+ height: 28px;
146
+ padding: 0 10px;
147
+ border: none;
148
+ border-radius: 6px;
149
+ font-size: 13px;
150
+ font-family: var(--font-body);
151
+ cursor: pointer;
152
+ display: inline-flex;
153
+ align-items: center;
154
+ gap: 4px;
155
+ background: transparent;
156
+ color: var(--text-muted);
157
+ transition: background 0.12s;
158
+ }
159
+ .header-btn:hover { background: var(--bg-muted); color: var(--text); }
160
+ .header-btn.primary {
161
+ background: var(--accent);
162
+ color: #fff;
163
+ font-weight: 500;
164
+ }
165
+ .header-btn.primary:hover { background: #0d6b5e; }
166
+ select.speed-select {
167
+ height: 28px;
168
+ padding: 0 6px;
169
+ border: 1px solid var(--border);
170
+ border-radius: 6px;
171
+ font-size: 12px;
172
+ font-family: var(--font-mono);
173
+ background: var(--bg-surface);
174
+ color: var(--text-muted);
175
+ cursor: pointer;
176
+ outline: none;
177
+ }
178
+ select.speed-select:hover { border-color: rgba(15,15,15,0.15); }
179
+ .transport-speed {
180
+ margin-left: 2px;
181
+ flex-shrink: 0;
182
+ }
183
+
184
+ /* ─── Main layout ─── */
185
+ .main {
186
+ display: flex;
187
+ flex: 1;
188
+ overflow: hidden;
189
+ }
190
+
191
+ /* ─── Left Sidebar ─── */
192
+ .sidebar {
193
+ width: var(--sidebar-w);
194
+ flex-shrink: 0;
195
+ background: var(--bg-surface);
196
+ border-right: 1px solid var(--border);
197
+ display: flex;
198
+ flex-direction: column;
199
+ overflow-y: auto;
200
+ }
201
+ .sidebar-section {
202
+ padding: 12px 14px;
203
+ }
204
+ .sidebar-section + .sidebar-section {
205
+ border-top: 1px solid var(--divider);
206
+ }
207
+
208
+ /* Video */
209
+ .video-wrap {
210
+ padding: 10px 10px 0;
211
+ }
212
+ #player {
213
+ width: 100%;
214
+ aspect-ratio: ${videoAspectRatio};
215
+ object-fit: contain;
216
+ border-radius: 8px;
217
+ background: #000;
218
+ display: block;
219
+ }
220
+
221
+ /* Transport row */
222
+ .transport {
223
+ display: flex;
224
+ align-items: center;
225
+ gap: 8px;
226
+ padding: 10px 14px;
227
+ }
228
+ .transport-btn {
229
+ width: 30px;
230
+ height: 30px;
231
+ border: none;
232
+ border-radius: 6px;
233
+ background: var(--bg-muted);
234
+ color: var(--text-muted);
235
+ font-size: 14px;
236
+ cursor: pointer;
237
+ display: flex;
238
+ align-items: center;
239
+ justify-content: center;
240
+ transition: background 0.12s;
241
+ }
242
+ .transport-btn:hover { background: #eae9e5; color: var(--text); }
243
+ .transport-btn.playing { background: var(--accent-soft); color: var(--accent); }
244
+ #time {
245
+ font-family: var(--font-mono);
246
+ font-size: 13px;
247
+ color: var(--text-muted);
248
+ margin-left: auto;
249
+ }
250
+
251
+ /* Cards */
252
+ .card {
253
+ background: var(--bg-subtle);
254
+ border-radius: 8px;
255
+ padding: 12px;
256
+ }
257
+ .card-title {
258
+ font-size: 11px;
259
+ font-weight: 600;
260
+ text-transform: uppercase;
261
+ letter-spacing: 0.5px;
262
+ color: var(--text-faint);
263
+ margin-bottom: 10px;
264
+ }
265
+
266
+ /* Clip preview card */
267
+ .clip-row {
268
+ display: flex;
269
+ align-items: baseline;
270
+ gap: 6px;
271
+ margin-bottom: 8px;
272
+ }
273
+ .clip-time-big {
274
+ font-size: 22px;
275
+ font-weight: 600;
276
+ font-family: var(--font-mono);
277
+ color: var(--accent);
278
+ }
279
+ .clip-arrow {
280
+ font-size: 14px;
281
+ color: var(--text-faint);
282
+ }
283
+ .clip-time-old {
284
+ font-size: 15px;
285
+ font-family: var(--font-mono);
286
+ color: var(--text-muted);
287
+ text-decoration: line-through;
288
+ text-decoration-color: var(--text-faint);
289
+ }
290
+ .clip-bar-wrap {
291
+ height: 6px;
292
+ border-radius: 3px;
293
+ background: var(--deleted-bg);
294
+ overflow: hidden;
295
+ margin-bottom: 6px;
296
+ }
297
+ .clip-bar-keep {
298
+ height: 100%;
299
+ background: var(--accent);
300
+ border-radius: 3px;
301
+ transition: width 0.3s;
302
+ }
303
+ .clip-saved {
304
+ font-size: 12px;
305
+ color: var(--text-muted);
306
+ }
307
+ .clip-saved b { color: var(--accent-text); font-weight: 600; }
308
+
309
+ /* Keyboard hints */
310
+ kbd {
311
+ display: inline-block;
312
+ font-family: var(--font-mono);
313
+ font-size: 11px;
314
+ background: var(--bg-muted);
315
+ border: 1px solid var(--border);
316
+ border-radius: 4px;
317
+ padding: 1px 5px;
318
+ color: var(--text);
319
+ white-space: nowrap;
320
+ }
321
+
322
+ .shortcut-strip {
323
+ min-height: 42px;
324
+ background: var(--bg-surface);
325
+ border-bottom: 1px solid var(--border);
326
+ display: flex;
327
+ align-items: center;
328
+ gap: 14px;
329
+ padding: 7px 16px;
330
+ flex-shrink: 0;
331
+ overflow-x: auto;
332
+ }
333
+ .shortcut-title {
334
+ font-size: 12px;
335
+ font-weight: 600;
336
+ color: var(--text);
337
+ white-space: nowrap;
338
+ }
339
+ .shortcut-list {
340
+ display: flex;
341
+ align-items: center;
342
+ gap: 12px;
343
+ min-width: 0;
344
+ }
345
+ .shortcut-item {
346
+ display: inline-flex;
347
+ align-items: center;
348
+ gap: 5px;
349
+ font-size: 12px;
350
+ color: var(--text-muted);
351
+ white-space: nowrap;
352
+ }
353
+ .shortcut-item.primary {
354
+ color: var(--accent-text);
355
+ font-weight: 500;
356
+ }
357
+ .shortcut-item.primary kbd {
358
+ background: var(--accent-soft);
359
+ border-color: transparent;
360
+ color: var(--accent-text);
361
+ }
362
+
363
+ /* ─── Right panel ─── */
364
+ .right-panel {
365
+ flex: 1;
366
+ display: flex;
367
+ flex-direction: column;
368
+ overflow: hidden;
369
+ }
370
+
371
+ /* Filter bar */
372
+ .filter-bar {
373
+ height: 40px;
374
+ background: var(--bg-surface);
375
+ border-bottom: 1px solid var(--border);
376
+ display: flex;
377
+ align-items: center;
378
+ padding: 0 16px;
379
+ gap: 6px;
380
+ flex-shrink: 0;
381
+ overflow-x: auto;
382
+ }
383
+ .filter-bar::-webkit-scrollbar,
384
+ .shortcut-strip::-webkit-scrollbar { display: none; }
385
+ .search-box {
386
+ display: flex;
387
+ align-items: center;
388
+ gap: 6px;
389
+ background: var(--bg-muted);
390
+ border-radius: 6px;
391
+ padding: 0 10px;
392
+ height: 28px;
393
+ font-size: 13px;
394
+ color: var(--text-faint);
395
+ cursor: text;
396
+ min-width: 140px;
397
+ }
398
+ .search-box input {
399
+ border: none;
400
+ background: transparent;
401
+ outline: none;
402
+ font-size: 13px;
403
+ font-family: var(--font-body);
404
+ color: var(--text);
405
+ width: 100%;
406
+ }
407
+ .search-box input::placeholder { color: var(--text-faint); }
408
+ .search-box .hint {
409
+ font-family: var(--font-mono);
410
+ font-size: 10px;
411
+ color: var(--text-faint);
412
+ background: var(--bg-surface);
413
+ border: 1px solid var(--border);
414
+ border-radius: 3px;
415
+ padding: 0 4px;
416
+ line-height: 16px;
417
+ }
418
+ .filter-divider {
419
+ width: 1px;
420
+ height: 16px;
421
+ background: var(--border);
422
+ margin: 0 4px;
423
+ }
424
+ .filter-btn {
425
+ height: 26px;
426
+ padding: 0 10px;
427
+ border: 1px solid var(--border);
428
+ border-radius: 14px;
429
+ background: var(--bg-surface);
430
+ font-size: 12px;
431
+ font-family: var(--font-body);
432
+ color: var(--text-muted);
433
+ cursor: pointer;
434
+ transition: all 0.12s;
435
+ white-space: nowrap;
436
+ }
437
+ .filter-btn:hover { background: var(--bg-muted); border-color: rgba(15,15,15,0.12); }
438
+ .filter-btn.active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
439
+ .filter-summary {
440
+ margin-left: auto;
441
+ font-size: 12px;
442
+ color: var(--text-faint);
443
+ font-family: var(--font-mono);
444
+ white-space: nowrap;
445
+ }
446
+
447
+ /* Transcript body */
448
+ .transcript-body {
449
+ flex: 1;
450
+ overflow-y: auto;
451
+ padding: 16px 24px 60px;
452
+ }
453
+ .content {
454
+ line-height: 2.4;
455
+ max-width: 720px;
456
+ }
457
+
458
+ /* Chapter header */
459
+ .chapter-header {
460
+ display: flex;
461
+ align-items: center;
462
+ gap: 10px;
463
+ margin: 24px 0 8px;
464
+ user-select: none;
465
+ }
466
+ .chapter-header:first-child { margin-top: 0; }
467
+ .chapter-num {
468
+ font-family: var(--font-mono);
469
+ font-size: 12px;
470
+ font-weight: 600;
471
+ color: var(--text-faint);
472
+ background: var(--bg-muted);
473
+ width: 24px;
474
+ height: 24px;
475
+ display: flex;
476
+ align-items: center;
477
+ justify-content: center;
478
+ border-radius: 6px;
479
+ flex-shrink: 0;
480
+ }
481
+ .chapter-range {
482
+ font-family: var(--font-mono);
483
+ font-size: 12px;
484
+ color: var(--text-faint);
485
+ flex-shrink: 0;
486
+ }
487
+ .chapter-line {
488
+ flex: 1;
489
+ height: 1px;
490
+ background: var(--divider);
491
+ }
492
+ .chapter-count {
493
+ font-size: 11px;
494
+ color: var(--text-faint);
495
+ flex-shrink: 0;
496
+ }
497
+
498
+ /* Words — two states */
499
+ .word {
500
+ display: inline;
501
+ padding: 2px 1px;
502
+ border-radius: 3px;
503
+ cursor: pointer;
504
+ transition: all 0.1s;
505
+ font-size: 15px;
506
+ color: var(--text);
507
+ }
508
+ .word:hover { background: var(--bg-muted); }
509
+ .word.selected {
510
+ color: var(--text-faint);
511
+ text-decoration: line-through;
512
+ text-decoration-color: var(--text-muted);
513
+ }
514
+ .word.selected:hover { background: var(--deleted-bg); }
515
+ .word.current {
516
+ background: var(--highlight-bg);
517
+ color: var(--highlight-fg);
518
+ border-radius: 3px;
519
+ text-decoration: none;
520
+ }
521
+ /* Gap pills */
522
+ .gap {
523
+ display: inline-block;
524
+ background: var(--bg-muted);
525
+ border: 1px solid #d9d7d0;
526
+ color: var(--text-muted);
527
+ padding: 1px 8px;
528
+ margin: 1px 2px;
529
+ border-radius: 10px;
530
+ font-size: 11px;
531
+ font-family: var(--font-mono);
532
+ cursor: pointer;
533
+ transition: all 0.1s;
534
+ vertical-align: middle;
535
+ line-height: 18px;
536
+ }
537
+ .gap:hover { background: #eae9e5; border-color: #cccac3; }
538
+ .gap.selected {
539
+ background: #e8e8e6;
540
+ color: var(--text-faint);
541
+ text-decoration: line-through;
542
+ border-color: #d4d3ce;
543
+ }
544
+ .gap.current {
545
+ background: var(--highlight-bg);
546
+ color: var(--highlight-fg);
547
+ border-color: #e8d89c;
548
+ text-decoration: none;
549
+ }
550
+ /* Bottom legend */
551
+ .bottom-legend {
552
+ height: 32px;
553
+ background: var(--bg-surface);
554
+ border-top: 1px solid var(--border);
555
+ display: flex;
556
+ align-items: center;
557
+ justify-content: center;
558
+ gap: 16px;
559
+ font-size: 12px;
560
+ color: var(--text-faint);
561
+ flex-shrink: 0;
562
+ }
563
+ .legend-item {
564
+ display: flex;
565
+ align-items: center;
566
+ gap: 5px;
567
+ }
568
+ .legend-swatch {
569
+ display: inline-block;
570
+ width: 28px;
571
+ font-size: 12px;
572
+ text-align: center;
573
+ }
574
+ .legend-swatch.del {
575
+ color: var(--text-faint);
576
+ text-decoration: line-through;
577
+ text-decoration-color: var(--text-muted);
578
+ }
579
+ .legend-swatch.normal { color: var(--text); }
580
+ .legend-swatch.playing {
581
+ background: var(--highlight-bg);
582
+ color: var(--highlight-fg);
583
+ border-radius: 3px;
584
+ padding: 0 2px;
585
+ }
586
+
587
+ /* ─── Loading overlay ─── */
588
+ .loading-overlay {
589
+ display: none;
590
+ position: fixed;
591
+ top: 0; left: 0;
592
+ width: 100%; height: 100%;
593
+ background: rgba(255,255,255,0.92);
594
+ backdrop-filter: blur(4px);
595
+ z-index: 9999;
596
+ justify-content: center;
597
+ align-items: center;
598
+ flex-direction: column;
599
+ }
600
+ .loading-overlay.show { display: flex; }
601
+ .loading-spinner {
602
+ width: 48px;
603
+ height: 48px;
604
+ border: 3px solid var(--bg-muted);
605
+ border-top-color: var(--accent);
606
+ border-radius: 50%;
607
+ animation: spin 0.8s linear infinite;
608
+ }
609
+ @keyframes spin { to { transform: rotate(360deg); } }
610
+ .loading-text {
611
+ margin-top: 20px;
612
+ font-size: 16px;
613
+ font-weight: 500;
614
+ color: var(--text);
615
+ }
616
+ .loading-progress-container {
617
+ margin-top: 16px;
618
+ width: 260px;
619
+ height: 4px;
620
+ background: var(--bg-muted);
621
+ border-radius: 2px;
622
+ overflow: hidden;
623
+ }
624
+ .loading-progress-bar {
625
+ height: 100%;
626
+ background: var(--accent);
627
+ width: 0%;
628
+ transition: width 0.3s ease;
629
+ border-radius: 2px;
630
+ }
631
+ .loading-time {
632
+ margin-top: 12px;
633
+ font-size: 13px;
634
+ color: var(--text-muted);
635
+ }
636
+ .loading-estimate {
637
+ margin-top: 6px;
638
+ font-size: 12px;
639
+ color: var(--text-faint);
640
+ }
641
+
642
+ /* Scrollbar */
643
+ .transcript-body::-webkit-scrollbar,
644
+ .sidebar::-webkit-scrollbar { width: 6px; }
645
+ .transcript-body::-webkit-scrollbar-track,
646
+ .sidebar::-webkit-scrollbar-track { background: transparent; }
647
+ .transcript-body::-webkit-scrollbar-thumb,
648
+ .sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }
649
+ .transcript-body::-webkit-scrollbar-thumb:hover,
650
+ .sidebar::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }
651
+
652
+ @media (max-width: 820px), (max-aspect-ratio: 3 / 4) {
653
+ .header {
654
+ padding: 0 10px;
655
+ gap: 8px;
656
+ }
657
+ .header-left {
658
+ min-width: 0;
659
+ }
660
+ .header-left .logo {
661
+ overflow: hidden;
662
+ text-overflow: ellipsis;
663
+ }
664
+ .header-left .badge {
665
+ display: none;
666
+ }
667
+ .header-right {
668
+ flex-shrink: 0;
669
+ }
670
+ .main {
671
+ flex-direction: column;
672
+ }
673
+ .sidebar {
674
+ width: 100%;
675
+ max-height: 58vh;
676
+ border-right: 0;
677
+ border-bottom: 1px solid var(--border);
678
+ }
679
+ .video-wrap {
680
+ display: flex;
681
+ justify-content: center;
682
+ padding: 8px 10px 0;
683
+ }
684
+ #player {
685
+ width: auto;
686
+ height: min(42vh, 520px);
687
+ max-width: calc(100vw - 20px);
688
+ }
689
+ .transport {
690
+ padding: 8px 12px;
691
+ gap: 6px;
692
+ }
693
+ .sidebar-section {
694
+ padding: 8px 12px 10px;
695
+ }
696
+ .card {
697
+ padding: 10px;
698
+ }
699
+ .card-title {
700
+ margin-bottom: 6px;
701
+ }
702
+ .clip-row {
703
+ margin-bottom: 6px;
704
+ }
705
+ .clip-time-big {
706
+ font-size: 18px;
707
+ }
708
+ .right-panel {
709
+ width: 100%;
710
+ min-height: 0;
711
+ }
712
+ .filter-bar {
713
+ height: 38px;
714
+ padding: 0 12px;
715
+ }
716
+ .shortcut-strip {
717
+ min-height: 38px;
718
+ padding: 6px 12px;
719
+ gap: 10px;
720
+ }
721
+ .shortcut-list {
722
+ gap: 10px;
723
+ }
724
+ .transcript-body {
725
+ padding: 12px 14px 56px;
726
+ }
727
+ .content {
728
+ max-width: none;
729
+ line-height: 2.25;
730
+ }
731
+ .bottom-legend {
732
+ justify-content: flex-start;
733
+ overflow-x: auto;
734
+ padding: 0 12px;
735
+ }
736
+ .bottom-legend::-webkit-scrollbar {
737
+ display: none;
738
+ }
739
+ }
740
+
741
+ @media (max-width: 520px) {
742
+ .header-btn {
743
+ padding: 0 8px;
744
+ }
745
+ .header-btn:not(.primary) .header-btn-label {
746
+ display: none;
747
+ }
748
+ .search-box {
749
+ min-width: 120px;
750
+ }
751
+ #time {
752
+ font-size: 12px;
753
+ }
754
+ select.speed-select {
755
+ width: 64px;
756
+ }
757
+ .shortcut-title {
758
+ display: none;
759
+ }
760
+ }
761
+ </style>
762
+ </head>
763
+ <body>
764
+ <!-- Loading overlay -->
765
+ <div class="loading-overlay" id="loadingOverlay">
766
+ <div class="loading-spinner"></div>
767
+ <div class="loading-text">正在剪辑...</div>
768
+ <div class="loading-progress-container">
769
+ <div class="loading-progress-bar" id="loadingProgress"></div>
770
+ </div>
771
+ <div class="loading-time" id="loadingTime">已等待 0 秒</div>
772
+ <div class="loading-estimate" id="loadingEstimate">预估剩余: 计算中...</div>
773
+ </div>
774
+
775
+ <!-- Header -->
776
+ <div class="header">
777
+ <div class="header-left">
778
+ <span class="logo"><span class="icon">&#9986;</span> 剪口播 · ${path.basename(videoFile)}</span>
779
+ <span class="badge">已分析</span>
780
+ </div>
781
+ <div class="header-right">
782
+ <button class="header-btn" onclick="copyDeleteList()" title="复制删除列表">
783
+ <span>&#128203;</span><span class="header-btn-label">字幕</span>
784
+ </button>
785
+ <button class="header-btn primary" onclick="executeCut()">执行剪辑</button>
786
+ </div>
787
+ </div>
788
+
789
+ <!-- Main -->
790
+ <div class="main">
791
+ <!-- Left Sidebar -->
792
+ <div class="sidebar">
793
+ <div class="video-wrap">
794
+ <video id="player" src="${videoBaseName}" preload="auto"></video>
795
+ </div>
796
+
797
+ <!-- Transport -->
798
+ <div class="transport">
799
+ <button class="transport-btn" onclick="player.currentTime=Math.max(0,player.currentTime-5)" title="-5s">&#9198;</button>
800
+ <button class="transport-btn" id="playBtn" onclick="togglePlay()" title="播放/暂停">&#9654;</button>
801
+ <button class="transport-btn" onclick="player.currentTime+=5" title="+5s">&#9197;</button>
802
+ <select class="speed-select transport-speed" id="speed" onchange="player.playbackRate=parseFloat(this.value)" title="播放速度">
803
+ <option value="0.5">0.5x</option>
804
+ <option value="0.75">0.75x</option>
805
+ <option value="1" selected>1.0x</option>
806
+ <option value="1.25">1.25x</option>
807
+ <option value="1.5">1.5x</option>
808
+ <option value="2">2.0x</option>
809
+ </select>
810
+ <span id="time">00:00 / 00:00</span>
811
+ </div>
812
+
813
+ <!-- Clip preview -->
814
+ <div class="sidebar-section">
815
+ <div class="card" id="clipCard">
816
+ <div class="card-title">剪辑预览</div>
817
+ <div class="clip-row">
818
+ <span class="clip-time-old" id="clipOld">--:--</span>
819
+ <span class="clip-arrow">&rarr;</span>
820
+ <span class="clip-time-big" id="clipNew">--:--</span>
821
+ </div>
822
+ <div class="clip-bar-wrap">
823
+ <div class="clip-bar-keep" id="clipBar" style="width:100%"></div>
824
+ </div>
825
+ <div class="clip-saved" id="clipSaved">选中后实时预览</div>
826
+ </div>
827
+ </div>
828
+
829
+ </div>
830
+
831
+ <!-- Right panel -->
832
+ <div class="right-panel">
833
+ <!-- Filter bar -->
834
+ <div class="filter-bar">
835
+ <div class="search-box">
836
+ <span style="font-size:14px;color:var(--text-faint)">&#128269;</span>
837
+ <input type="text" id="searchInput" placeholder="搜索..." oninput="filterSearch(this.value)">
838
+ <span class="hint">&#8984;K</span>
839
+ </div>
840
+ <div class="filter-divider"></div>
841
+ <button class="filter-btn active" data-filter="all" onclick="setFilter('all',this)">全部 <span id="fAll">0</span></button>
842
+ <button class="filter-btn" data-filter="silence" onclick="setFilter('silence',this)">静音 <span id="fSilence">0</span></button>
843
+ <button class="filter-btn" data-filter="filler" onclick="setFilter('filler',this)">语气词 <span id="fFiller">0</span></button>
844
+ <button class="filter-btn" data-filter="stutter" onclick="setFilter('stutter',this)">卡顿 <span id="fStutter">0</span></button>
845
+ <button class="filter-btn" data-filter="repeat" onclick="setFilter('repeat',this)">重说 <span id="fRepeat">0</span></button>
846
+ <span class="filter-summary">已选 <span id="selCount">0</span> / <span id="totalCount">0</span></span>
847
+ </div>
848
+
849
+ <!-- Shortcut strip -->
850
+ <div class="shortcut-strip">
851
+ <span class="shortcut-title">快捷键</span>
852
+ <div class="shortcut-list">
853
+ <span class="shortcut-item primary"><kbd>左键拖动</kbd><span>批量选择 / 取消</span></span>
854
+ <span class="shortcut-item"><kbd>双击</kbd><span>切换选中</span></span>
855
+ <span class="shortcut-item"><kbd>Space</kbd><span>播放 / 暂停</span></span>
856
+ <span class="shortcut-item"><kbd>&larr; &rarr;</kbd><span>跳 1 秒</span></span>
857
+ <span class="shortcut-item"><kbd>Shift + &larr;&rarr;</kbd><span>跳 5 秒</span></span>
858
+ <span class="shortcut-item"><kbd>&#8984;K</kbd><span>搜索</span></span>
859
+ </div>
860
+ </div>
861
+
862
+ <!-- Transcript body -->
863
+ <div class="transcript-body" id="transcriptBody">
864
+ <div class="content" id="content"></div>
865
+ </div>
866
+
867
+ <!-- Bottom legend -->
868
+ <div class="bottom-legend">
869
+ <div class="legend-item"><span class="legend-swatch del">删除</span><span>已选中</span></div>
870
+ <div class="legend-item"><span class="legend-swatch normal">保留</span><span>未选中</span></div>
871
+ <div class="legend-item"><span class="legend-swatch playing">播放</span><span>当前词</span></div>
872
+ <span style="color:var(--divider)">|</span>
873
+ <span>单击跳转 · 双击切换 · 左键拖动批量</span>
874
+ </div>
875
+ </div>
876
+ </div>
877
+
878
+ <script>
879
+ const words = ${JSON.stringify(words)};
880
+ const autoSelected = new Set(${JSON.stringify(autoSelected)});
881
+ const selected = new Set(autoSelected);
882
+
883
+ // 自动保存状态(必须在 rebuildSkipIntervals 之前声明,否则 TDZ)
884
+ let saveTimer = null;
885
+ let autosaveEnabled = false;
886
+
887
+ const player = document.getElementById('player');
888
+ const timeDisplay = document.getElementById('time');
889
+ const playBtn = document.getElementById('playBtn');
890
+
891
+ function togglePlay() {
892
+ if (player.paused) player.play();
893
+ else player.pause();
894
+ }
895
+ player.addEventListener('play', () => { playBtn.classList.add('playing'); playBtn.innerHTML = '&#9646;&#9646;'; });
896
+ player.addEventListener('pause', () => { playBtn.classList.remove('playing'); playBtn.innerHTML = '&#9654;'; });
897
+
898
+ const content = document.getElementById('content');
899
+ let elements = [];
900
+ let isSelecting = false;
901
+ const dragSelect = {
902
+ pending: false,
903
+ startIndex: -1,
904
+ lastIndex: -1,
905
+ mode: 'add',
906
+ startX: 0,
907
+ startY: 0,
908
+ snapshot: null
909
+ };
910
+
911
+ // 当前激活的 filter
912
+ let activeFilter = 'all';
913
+ let searchQuery = '';
914
+
915
+ function formatTime(sec) {
916
+ if (!sec || isNaN(sec)) return '00:00';
917
+ const m = Math.floor(sec / 60);
918
+ const s = Math.floor(sec % 60);
919
+ return \`\${m.toString().padStart(2, '0')}:\${s.toString().padStart(2, '0')}\`;
920
+ }
921
+
922
+ function formatDuration(sec) {
923
+ const totalSec = parseFloat(sec);
924
+ const m = Math.floor(totalSec / 60);
925
+ const s = (totalSec % 60).toFixed(1);
926
+ if (m > 0) return \`\${m}分\${s}秒 (\${totalSec}s)\`;
927
+ return \`\${s}秒\`;
928
+ }
929
+
930
+ function setSelected(i, shouldSelect) {
931
+ if (!words[i]) return;
932
+ if (shouldSelect) {
933
+ selected.add(i);
934
+ if (elements[i]) elements[i].classList.add('selected');
935
+ } else {
936
+ selected.delete(i);
937
+ if (elements[i]) elements[i].classList.remove('selected');
938
+ }
939
+ }
940
+
941
+ function applySelectionRange(from, to, mode) {
942
+ const min = Math.min(from, to);
943
+ const max = Math.max(from, to);
944
+ const shouldSelect = mode === 'add';
945
+ for (let j = min; j <= max; j++) {
946
+ setSelected(j, shouldSelect);
947
+ }
948
+ updateStats();
949
+ }
950
+
951
+ function restoreSelectionSnapshot(snapshot) {
952
+ selected.clear();
953
+ snapshot.forEach(i => selected.add(i));
954
+ elements.forEach((el, i) => {
955
+ if (el) el.classList.toggle('selected', selected.has(i));
956
+ });
957
+ }
958
+
959
+ function applyLiveSelectionRange(to) {
960
+ if (!dragSelect.snapshot) return;
961
+ restoreSelectionSnapshot(dragSelect.snapshot);
962
+ applySelectionRange(dragSelect.startIndex, to, dragSelect.mode);
963
+ }
964
+
965
+ function getIndexedTarget(e) {
966
+ const direct = e.target && e.target.closest ? e.target.closest('[data-index]') : null;
967
+ if (direct) return direct;
968
+ const atPoint = document.elementFromPoint(e.clientX, e.clientY);
969
+ return atPoint && atPoint.closest ? atPoint.closest('[data-index]') : null;
970
+ }
971
+
972
+ // ─── 章节分割(gap >= 1.5s) ───
973
+ function buildChapters() {
974
+ const chapters = [];
975
+ let current = { startIdx: 0, startTime: words.length ? words[0].start : 0, endTime: 0, suggestions: 0 };
976
+
977
+ for (let i = 0; i < words.length; i++) {
978
+ const w = words[i];
979
+ current.endTime = w.end;
980
+ if (autoSelected.has(i)) current.suggestions++;
981
+
982
+ // gap >= 1.5s → 新章节
983
+ if (w.isGap && (w.end - w.start) >= 1.5 && i < words.length - 1) {
984
+ current.endIdx = i;
985
+ chapters.push(current);
986
+ current = { startIdx: i + 1, startTime: words[i + 1].start, endTime: 0, suggestions: 0 };
987
+ }
988
+ }
989
+ current.endIdx = words.length - 1;
990
+ chapters.push(current);
991
+ return chapters;
992
+ }
993
+
994
+ // ─── 预选分类统计 ───
995
+ function categorize(i) {
996
+ const w = words[i];
997
+ if (w.isGap) return 'silence';
998
+ const t = (w.text || '').trim().toLowerCase();
999
+ if (/^(嗯|啊|呃|额|哦|噢|唔|emm|em|uhm|uh|hmm|嘶)$/.test(t)) return 'filler';
1000
+ if (w.reason && /重说|repeat/i.test(w.reason)) return 'repeat';
1001
+ if (w.reason && /卡顿|stutter/i.test(w.reason)) return 'stutter';
1002
+ if (w.reason && /残句/i.test(w.reason)) return 'incomplete';
1003
+ return 'other';
1004
+ }
1005
+
1006
+ function countByCategory() {
1007
+ const counts = { silence: 0, filler: 0, stutter: 0, repeat: 0, incomplete: 0, other: 0 };
1008
+ autoSelected.forEach(i => {
1009
+ const cat = categorize(i);
1010
+ if (counts[cat] !== undefined) counts[cat]++;
1011
+ });
1012
+ return counts;
1013
+ }
1014
+
1015
+ // ─── 渲染 ───
1016
+ function render() {
1017
+ content.innerHTML = '';
1018
+ elements = new Array(words.length);
1019
+
1020
+ const chapters = buildChapters();
1021
+
1022
+ chapters.forEach((ch, ci) => {
1023
+ // Chapter header
1024
+ const header = document.createElement('div');
1025
+ header.className = 'chapter-header';
1026
+ const num = String(ci + 1).padStart(2, '0');
1027
+ header.innerHTML = \`
1028
+ <span class="chapter-num">\${num}</span>
1029
+ <span class="chapter-range">\${formatTime(ch.startTime)} — \${formatTime(ch.endTime)}</span>
1030
+ <div class="chapter-line"></div>
1031
+ <span class="chapter-count">\${ch.suggestions ? ch.suggestions + ' 建议' : ''}</span>
1032
+ \`;
1033
+ content.appendChild(header);
1034
+
1035
+ // Words in this chapter
1036
+ for (let i = ch.startIdx; i <= ch.endIdx; i++) {
1037
+ const word = words[i];
1038
+ const el = document.createElement(word.isGap ? 'span' : 'span');
1039
+ el.className = word.isGap ? 'gap' : 'word';
1040
+
1041
+ if (selected.has(i)) el.classList.add('selected');
1042
+
1043
+ if (word.isGap) {
1044
+ const duration = (word.end - word.start).toFixed(1);
1045
+ el.textContent = duration + 's';
1046
+ } else {
1047
+ el.textContent = word.text;
1048
+ }
1049
+
1050
+ el.dataset.index = i;
1051
+
1052
+ // 双击选中/取消
1053
+ el.ondblclick = () => toggle(i);
1054
+
1055
+ // 左键拖动批量选择;单击仍跳转
1056
+ el.onmousedown = (e) => {
1057
+ if (e.button !== 0) return;
1058
+ isSelecting = false;
1059
+ const mode = selected.has(i) ? 'remove' : 'add';
1060
+ dragSelect.pending = true;
1061
+ dragSelect.startIndex = i;
1062
+ dragSelect.lastIndex = i;
1063
+ dragSelect.mode = mode;
1064
+ dragSelect.startX = e.clientX;
1065
+ dragSelect.startY = e.clientY;
1066
+ dragSelect.snapshot = new Set(selected);
1067
+ e.preventDefault();
1068
+ };
1069
+
1070
+ content.appendChild(el);
1071
+ elements[i] = el;
1072
+
1073
+ // 非 gap 之间加空格
1074
+ if (!word.isGap) {
1075
+ const next = words[i + 1];
1076
+ if (next && !next.isGap && i < ch.endIdx) {
1077
+ content.appendChild(document.createTextNode(' '));
1078
+ }
1079
+ }
1080
+ }
1081
+ });
1082
+
1083
+ updateStats();
1084
+ updateFilterCounts();
1085
+ }
1086
+
1087
+ // 左键拖动多选
1088
+ document.getElementById('content').addEventListener('mousemove', e => {
1089
+ if (!dragSelect.pending && !isSelecting) return;
1090
+ if (e.buttons !== 1) {
1091
+ finishDragSelect(false);
1092
+ return;
1093
+ }
1094
+
1095
+ const target = getIndexedTarget(e);
1096
+ if (!target) return;
1097
+
1098
+ const i = parseInt(target.dataset.index);
1099
+ const movedEnough = Math.abs(e.clientX - dragSelect.startX) > 3 || Math.abs(e.clientY - dragSelect.startY) > 3 || i !== dragSelect.startIndex;
1100
+
1101
+ if (!isSelecting) {
1102
+ if (!movedEnough) return;
1103
+ isSelecting = true;
1104
+ applyLiveSelectionRange(dragSelect.startIndex);
1105
+ }
1106
+
1107
+ if (Number.isInteger(i) && i !== dragSelect.lastIndex) {
1108
+ applyLiveSelectionRange(i);
1109
+ dragSelect.lastIndex = i;
1110
+ }
1111
+ });
1112
+
1113
+ document.addEventListener('mouseup', () => {
1114
+ finishDragSelect(true);
1115
+ });
1116
+
1117
+ function finishDragSelect(allowSingleClick) {
1118
+ if (!dragSelect.pending && !isSelecting) return;
1119
+ const wasSelecting = isSelecting;
1120
+ const clickIndex = dragSelect.startIndex;
1121
+
1122
+ dragSelect.pending = false;
1123
+ isSelecting = false;
1124
+ dragSelect.startIndex = -1;
1125
+ dragSelect.lastIndex = -1;
1126
+ dragSelect.snapshot = null;
1127
+
1128
+ if (wasSelecting) {
1129
+ rebuildSkipIntervals();
1130
+ } else if (allowSingleClick && words[clickIndex]) {
1131
+ player.currentTime = words[clickIndex].start;
1132
+ }
1133
+ }
1134
+
1135
+ function toggle(i) {
1136
+ finishDragSelect(false);
1137
+ if (selected.has(i)) {
1138
+ setSelected(i, false);
1139
+ } else {
1140
+ setSelected(i, true);
1141
+ }
1142
+ rebuildSkipIntervals();
1143
+ updateStats();
1144
+ }
1145
+
1146
+ function updateStats() {
1147
+ // Clip preview card
1148
+ const totalDur = words.length ? words[words.length - 1].end - words[0].start : 0;
1149
+ let deletedDur = 0;
1150
+ selected.forEach(i => { deletedDur += words[i].end - words[i].start; });
1151
+ const newDur = Math.max(0, totalDur - deletedDur);
1152
+ const pct = totalDur > 0 ? ((deletedDur / totalDur) * 100).toFixed(0) : 0;
1153
+ const keepPct = totalDur > 0 ? ((newDur / totalDur) * 100).toFixed(0) : 100;
1154
+
1155
+ document.getElementById('clipOld').textContent = formatTime(totalDur);
1156
+ document.getElementById('clipNew').textContent = formatTime(newDur);
1157
+ document.getElementById('clipBar').style.width = keepPct + '%';
1158
+ document.getElementById('clipSaved').innerHTML = deletedDur > 0
1159
+ ? \`删减 \${deletedDur.toFixed(1)}s · 节省 <b>\${pct}%</b>\`
1160
+ : '尚未选择删除片段';
1161
+
1162
+ // Filter summary
1163
+ document.getElementById('selCount').textContent = selected.size;
1164
+ document.getElementById('totalCount').textContent = words.length;
1165
+ }
1166
+
1167
+ function updateFilterCounts() {
1168
+ const counts = countByCategory();
1169
+ document.getElementById('fAll').textContent = words.length;
1170
+ document.getElementById('fSilence').textContent = counts.silence;
1171
+ document.getElementById('fFiller').textContent = counts.filler;
1172
+ document.getElementById('fStutter').textContent = counts.stutter;
1173
+ document.getElementById('fRepeat').textContent = counts.repeat;
1174
+ }
1175
+
1176
+ // ─── Filter ───
1177
+ function setFilter(type, btn) {
1178
+ activeFilter = type;
1179
+ document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
1180
+ btn.classList.add('active');
1181
+
1182
+ if (type === 'all') {
1183
+ // 显示所有
1184
+ elements.forEach(el => { if (el) el.style.display = ''; });
1185
+ document.querySelectorAll('.chapter-header').forEach(h => h.style.display = '');
1186
+ return;
1187
+ }
1188
+
1189
+ // 高亮该类型,滚到第一个
1190
+ let first = null;
1191
+ elements.forEach((el, i) => {
1192
+ if (!el) return;
1193
+ if (autoSelected.has(i) && categorize(i) === type) {
1194
+ el.style.display = '';
1195
+ el.style.outline = '2px solid var(--accent)';
1196
+ el.style.outlineOffset = '1px';
1197
+ el.style.borderRadius = '3px';
1198
+ if (!first) first = el;
1199
+ } else {
1200
+ el.style.display = '';
1201
+ el.style.outline = '';
1202
+ el.style.outlineOffset = '';
1203
+ }
1204
+ });
1205
+ if (first) first.scrollIntoView({ behavior: 'smooth', block: 'center' });
1206
+
1207
+ // 3 秒后去掉 outline
1208
+ setTimeout(() => {
1209
+ elements.forEach(el => { if (el) { el.style.outline = ''; el.style.outlineOffset = ''; } });
1210
+ }, 3000);
1211
+ }
1212
+
1213
+ // ─── Search ───
1214
+ function filterSearch(query) {
1215
+ searchQuery = query.trim().toLowerCase();
1216
+ if (!searchQuery) {
1217
+ elements.forEach(el => { if (el) el.style.display = ''; });
1218
+ document.querySelectorAll('.chapter-header').forEach(h => h.style.display = '');
1219
+ return;
1220
+ }
1221
+ let first = null;
1222
+ elements.forEach((el, i) => {
1223
+ if (!el) return;
1224
+ const w = words[i];
1225
+ const text = (w.text || '').toLowerCase();
1226
+ if (text.includes(searchQuery)) {
1227
+ el.style.outline = '2px solid var(--accent)';
1228
+ el.style.outlineOffset = '1px';
1229
+ if (!first) first = el;
1230
+ } else {
1231
+ el.style.outline = '';
1232
+ el.style.outlineOffset = '';
1233
+ }
1234
+ });
1235
+ if (first) first.scrollIntoView({ behavior: 'smooth', block: 'center' });
1236
+
1237
+ // 清除 outline 延迟
1238
+ clearTimeout(filterSearch._timer);
1239
+ filterSearch._timer = setTimeout(() => {
1240
+ elements.forEach(el => { if (el) { el.style.outline = ''; el.style.outlineOffset = ''; } });
1241
+ }, 4000);
1242
+ }
1243
+
1244
+ // ─── Web Audio API ───
1245
+ const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
1246
+ const source = audioCtx.createMediaElementSource(player);
1247
+ const gainNode = audioCtx.createGain();
1248
+ source.connect(gainNode);
1249
+ gainNode.connect(audioCtx.destination);
1250
+ player.addEventListener('play', () => { if (audioCtx.state === 'suspended') audioCtx.resume(); });
1251
+
1252
+ // 预计算跳过区间
1253
+ let skipIntervals = [];
1254
+ function rebuildSkipIntervals() {
1255
+ const sorted = Array.from(selected).sort((a, b) => a - b);
1256
+ skipIntervals = [];
1257
+ let i = 0;
1258
+ while (i < sorted.length) {
1259
+ let start = words[sorted[i]].start;
1260
+ let end = words[sorted[i]].end;
1261
+ let j = i + 1;
1262
+ while (j < sorted.length && words[sorted[j]].start - end < 0.1) {
1263
+ end = words[sorted[j]].end;
1264
+ j++;
1265
+ }
1266
+ skipIntervals.push({ start: start - 0.05, end });
1267
+ i = j;
1268
+ }
1269
+ autosave();
1270
+ }
1271
+ rebuildSkipIntervals();
1272
+
1273
+ // ─── 自动保存选中状态 ───
1274
+ function autosave() {
1275
+ if (!autosaveEnabled) return;
1276
+ clearTimeout(saveTimer);
1277
+ saveTimer = setTimeout(() => {
1278
+ const data = Array.from(selected).sort((a, b) => a - b);
1279
+ fetch('/api/save-selection', {
1280
+ method: 'POST',
1281
+ headers: { 'Content-Type': 'application/json' },
1282
+ body: JSON.stringify(data),
1283
+ }).catch(e => console.warn('autosave failed', e));
1284
+ }, 400);
1285
+ }
1286
+
1287
+ async function loadSavedSelection() {
1288
+ try {
1289
+ const r = await fetch('/api/load-selection');
1290
+ if (r.ok) {
1291
+ const data = await r.json();
1292
+ if (Array.isArray(data)) {
1293
+ selected.clear();
1294
+ data.forEach(i => selected.add(i));
1295
+ document.querySelectorAll('.word.selected, .gap.selected').forEach(el => el.classList.remove('selected'));
1296
+ selected.forEach(i => { if (elements[i]) elements[i].classList.add('selected'); });
1297
+ console.log('已加载保存的选中:', data.length);
1298
+ }
1299
+ }
1300
+ } catch (e) {
1301
+ console.warn('load failed', e);
1302
+ }
1303
+ autosaveEnabled = true;
1304
+ rebuildSkipIntervals();
1305
+ updateStats();
1306
+ }
1307
+
1308
+ // rAF tick
1309
+ let lastHighlight = -1;
1310
+ let skipLock = false;
1311
+ function tick() {
1312
+ requestAnimationFrame(tick);
1313
+ const t = player.currentTime;
1314
+
1315
+ if (!player.paused) {
1316
+ for (const iv of skipIntervals) {
1317
+ if (t >= iv.start && t < iv.end) {
1318
+ if (!skipLock) {
1319
+ skipLock = true;
1320
+ gainNode.gain.setValueAtTime(0, audioCtx.currentTime);
1321
+ player.currentTime = iv.end;
1322
+ }
1323
+ return;
1324
+ }
1325
+ }
1326
+ if (skipLock) {
1327
+ skipLock = false;
1328
+ gainNode.gain.setValueAtTime(1, audioCtx.currentTime);
1329
+ }
1330
+ }
1331
+
1332
+ timeDisplay.textContent = \`\${formatTime(t)} / \${formatTime(player.duration || 0)}\`;
1333
+
1334
+ // 高亮当前词
1335
+ let curr = -1;
1336
+ for (let i = 0; i < words.length; i++) {
1337
+ if (t >= words[i].start && t < words[i].end) { curr = i; break; }
1338
+ }
1339
+ if (curr !== lastHighlight) {
1340
+ if (lastHighlight >= 0 && elements[lastHighlight]) elements[lastHighlight].classList.remove('current');
1341
+ if (curr >= 0 && elements[curr]) {
1342
+ elements[curr].classList.add('current');
1343
+ elements[curr].scrollIntoView({ behavior: 'smooth', block: 'center' });
1344
+ }
1345
+ lastHighlight = curr;
1346
+ }
1347
+ }
1348
+ requestAnimationFrame(tick);
1349
+
1350
+ // ─── Actions ───
1351
+ function copyDeleteList() {
1352
+ const segments = [];
1353
+ const sortedSelected = Array.from(selected).sort((a, b) => a - b);
1354
+ sortedSelected.forEach(i => {
1355
+ const word = words[i];
1356
+ segments.push({ start: word.start, end: word.end });
1357
+ });
1358
+
1359
+ const merged = [];
1360
+ for (const seg of segments) {
1361
+ if (merged.length === 0) {
1362
+ merged.push({ ...seg });
1363
+ } else {
1364
+ const last = merged[merged.length - 1];
1365
+ if (Math.abs(seg.start - last.end) < 0.05) {
1366
+ last.end = seg.end;
1367
+ } else {
1368
+ merged.push({ ...seg });
1369
+ }
1370
+ }
1371
+ }
1372
+
1373
+ const json = JSON.stringify(merged, null, 2);
1374
+ navigator.clipboard.writeText(json).then(() => {
1375
+ alert('已复制 ' + merged.length + ' 个删除片段到剪贴板');
1376
+ });
1377
+ }
1378
+
1379
+ function clearAll() {
1380
+ selected.clear();
1381
+ elements.forEach((el, i) => {
1382
+ if (el) el.classList.remove('selected');
1383
+ });
1384
+ rebuildSkipIntervals();
1385
+ updateStats();
1386
+ }
1387
+
1388
+ async function executeCut() {
1389
+ const videoDuration = player.duration;
1390
+ const videoMinutes = (videoDuration / 60).toFixed(1);
1391
+ const estimatedTime = Math.max(5, Math.ceil(videoDuration / 4));
1392
+ const estMin = Math.floor(estimatedTime / 60);
1393
+ const estSec = estimatedTime % 60;
1394
+ const estText = estMin > 0 ? \`\${estMin}分\${estSec}秒\` : \`\${estSec}秒\`;
1395
+
1396
+ if (!confirm(\`确认执行剪辑?\\n\\n视频时长: \${videoMinutes} 分钟\\n预计耗时: \${estText} 起\\n\\n点击确定开始\`)) return;
1397
+
1398
+ const segments = [];
1399
+ const sortedSelected = Array.from(selected).sort((a, b) => a - b);
1400
+ sortedSelected.forEach(i => {
1401
+ const word = words[i];
1402
+ segments.push({ start: word.start, end: word.end });
1403
+ });
1404
+
1405
+ const overlay = document.getElementById('loadingOverlay');
1406
+ const loadingTimeEl = document.getElementById('loadingTime');
1407
+ const loadingProgress = document.getElementById('loadingProgress');
1408
+ const loadingEstimate = document.getElementById('loadingEstimate');
1409
+ overlay.classList.add('show');
1410
+ loadingEstimate.textContent = \`预估剩余: \${estText}\`;
1411
+
1412
+ const startTime = Date.now();
1413
+ const timer = setInterval(() => {
1414
+ const elapsed = Math.floor((Date.now() - startTime) / 1000);
1415
+ loadingTimeEl.textContent = \`已等待 \${elapsed} 秒\`;
1416
+ const progress = Math.min(95, (elapsed / estimatedTime) * 100);
1417
+ loadingProgress.style.width = progress + '%';
1418
+ const remaining = Math.max(0, estimatedTime - elapsed);
1419
+ if (remaining > 0) {
1420
+ loadingEstimate.textContent = \`预估剩余: \${remaining} 秒\`;
1421
+ } else {
1422
+ loadingEstimate.textContent = '即将完成...';
1423
+ }
1424
+ }, 500);
1425
+
1426
+ try {
1427
+ const res = await fetch('/api/cut', {
1428
+ method: 'POST',
1429
+ headers: { 'Content-Type': 'application/json' },
1430
+ body: JSON.stringify(segments)
1431
+ });
1432
+ const data = await res.json();
1433
+
1434
+ clearInterval(timer);
1435
+ loadingProgress.style.width = '100%';
1436
+ await new Promise(r => setTimeout(r, 300));
1437
+ overlay.classList.remove('show');
1438
+ loadingProgress.style.width = '0%';
1439
+ const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
1440
+
1441
+ if (data.success) {
1442
+ const msg = \`剪辑完成!(耗时 \${totalTime}s)\\n\\n输出文件: \${data.output}\\n\\n下一步:让 Agent 基于剪后视频重新转写,并 AI 校对字幕。\\n\\n时间统计:\\n 原时长: \${formatDuration(data.originalDuration)}\\n 新时长: \${formatDuration(data.newDuration)}\\n 删减: \${formatDuration(data.deletedDuration)} (\${data.savedPercent}%)\`;
1443
+ alert(msg);
1444
+ } else {
1445
+ alert('剪辑失败: ' + data.error);
1446
+ }
1447
+ } catch (err) {
1448
+ clearInterval(timer);
1449
+ overlay.classList.remove('show');
1450
+ loadingProgress.style.width = '0%';
1451
+ alert('请求失败: ' + err.message + '\\n\\n请确保使用 review_server.js 启动服务');
1452
+ }
1453
+ }
1454
+
1455
+ // ─── Keyboard shortcuts ───
1456
+ document.addEventListener('keydown', e => {
1457
+ // 忽略搜索框输入
1458
+ if (e.target.tagName === 'INPUT') return;
1459
+
1460
+ if (e.code === 'Space') {
1461
+ e.preventDefault();
1462
+ togglePlay();
1463
+ } else if (e.code === 'ArrowLeft') {
1464
+ e.preventDefault();
1465
+ player.currentTime = Math.max(0, player.currentTime - (e.shiftKey ? 5 : 1));
1466
+ } else if (e.code === 'ArrowRight') {
1467
+ e.preventDefault();
1468
+ player.currentTime = player.currentTime + (e.shiftKey ? 5 : 1);
1469
+ } else if (e.code === 'KeyK' && (e.metaKey || e.ctrlKey)) {
1470
+ e.preventDefault();
1471
+ document.getElementById('searchInput').focus();
1472
+ }
1473
+ });
1474
+
1475
+ render();
1476
+ loadSavedSelection();
1477
+ </script>
1478
+ </body>
1479
+ </html>`;
1480
+
1481
+ fs.writeFileSync('review.html', html);
1482
+ console.log('✅ 已生成 review.html');
1483
+ console.log('📌 启动服务器: node "$SKILL_DIR/scripts/review_server.js" 8899 "$VIDEO_PATH"');
1484
+ console.log('📌 打开: http://localhost:8899/review.html');