@lunagerm-studio/video-cut-skill 0.0.0-stage → 1.0.0
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.
- package/README.md +13 -2
- package/package.json +12 -4
- package/skills/ai-video-opening/SKILL.md +62 -0
- package/skills/ai-video-opening/references/export-and-validation.md +9 -0
- package/skills/ai-video-opening/references/motion-and-layout.md +7 -0
- package/skills/ai-video-opening/references/series-cases.md +7 -0
- package/skills/blue-white-ui-motion/SKILL.md +30 -0
- package/skills/blue-white-ui-motion/agents/openai.yaml +2 -0
- package/skills/blue-white-ui-motion/references/review.md +25 -0
- package/skills/chengfeng-videocut-skills/LICENSE +201 -0
- package/skills/chengfeng-videocut-skills/NOTICE.md +27 -0
- package/skills/chengfeng-videocut-skills/README.md +265 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/SKILL.md +37 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/agents/openai.yaml +2 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/cut_video.sh +182 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/detect_en_stutter.js +49 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_review.js +1484 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_srt_for_video.sh +75 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_subtitles.js +141 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/review_server.js +381 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/volcengine_transcribe.sh +224 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/watch_cut_done.js +86 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/SKILL.md +32 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/agents/openai.yaml +2 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/references/artifact-contracts.md +168 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/animation_style.cjs +53 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/export_final_video.cjs +200 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/serve_range_preview.cjs +128 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/user_config.cjs +80 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/write_render_mode.cjs +149 -0
- 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
- package/skills/chengfeng-videocut-skills//350/207/252/350/277/233/345/214/226/README.md +23 -0
- package/skills/chengfeng-videocut-skills//350/207/252/350/277/233/345/214/226/SKILL.md +126 -0
- package/skills/continuous-collage-motion/SKILL.md +30 -0
- package/skills/continuous-collage-motion/agents/openai.yaml +4 -0
- package/skills/continuous-collage-motion/references/reference-motion.md +32 -0
- package/skills/continuous-collage-motion/references/shot-plan.md +31 -0
- package/skills/continuous-collage-motion/references/style-check.md +17 -0
- package/skills/table-video/LICENSES/ATTRIBUTION.md +31 -0
- package/skills/table-video/LICENSES/CC-BY-4.0.txt +396 -0
- package/skills/table-video/LICENSES/MIT.txt +21 -0
- package/skills/table-video/SKILL.md +32 -0
- package/skills/table-video/SOURCES.md +61 -0
- package/skills/table-video/agents/openai.yaml +2 -0
- package/skills/table-video/references/complete-motion.md +97 -0
- package/skills/table-video/references/examples/01_/344/270/244/346/256/265/346/274/224/347/244/272.md +73 -0
- 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
- package/skills/table-video/references/examples/03_DESIGN/345/241/253/345/206/231/347/244/272/344/276/213.md +333 -0
- 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
- 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
- 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
- package/skills/table-video/references/experience//345/255/227/345/271/225/344/270/216/345/260/201/351/235/242.md +30 -0
- package/skills/table-video/references/experience//345/275/225/345/261/217/345/211/252/350/276/221.md +31 -0
- 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
- 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
- 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
- package/skills/table-video/references/intake.md +84 -0
- package/skills/table-video/references/library.md +26 -0
- package/skills/table-video/references/motion-check-method.md +147 -0
- package/skills/table-video/references/planning.md +62 -0
- package/skills/table-video/references/production.md +70 -0
- package/skills/table-video/references/project-rules.md +26 -0
- package/skills/table-video/references/review-and-repair.md +64 -0
- package/skills/table-video/references/self-diagnosis.md +46 -0
- package/skills/table-video/references/sop/01_/345/277/253/351/200/237/345/274/200/345/247/213.md +55 -0
- package/skills/table-video/references/sop/02_/345/210/266/344/275/234SOP.md +77 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/skills/table-video/references/state-contract.md +267 -0
- package/skills/table-video/references/style-and-motion.md +163 -0
- package/skills/table-video/schemas/request.schema.json +44 -0
- package/skills/table-video/schemas/state.schema.json +140 -0
- package/skills/table-video/scripts/cli.mjs +35 -0
- package/skills/table-video/scripts/core.mjs +977 -0
- package/skills/table-video/scripts/gain-proof.mjs +48 -0
- package/skills/table-video/scripts/init-project.mjs +7 -0
- package/skills/table-video/scripts/motion-audit.mjs +589 -0
- package/skills/table-video/scripts/motion-check.mjs +345 -0
- package/skills/table-video/scripts/motion-gates.mjs +997 -0
- package/skills/table-video/scripts/motion-observation.cjs +204 -0
- package/skills/table-video/scripts/preflight.mjs +24 -0
- package/skills/table-video/scripts/process-locate.mjs +57 -0
- package/skills/table-video/scripts/render-motion-example.mjs +143 -0
- package/skills/table-video/scripts/save-reference-image.mjs +249 -0
- package/skills/table-video/scripts/schema.mjs +71 -0
- package/skills/table-video/scripts/stillness.mjs +386 -0
- package/skills/table-video/scripts/storage.mjs +328 -0
- package/skills/table-video/scripts/workflow.mjs +24 -0
- package/skills/talking-head-motion-workflow/SKILL.md +36 -0
- package/skills/talking-head-motion-workflow/agents/openai.yaml +4 -0
- package/skills/talking-head-motion-workflow/references/cinematic-motion-and-sync.md +72 -0
- package/skills/talking-head-motion-workflow/references/classic-ui.md +11 -0
- package/skills/talking-head-motion-workflow/references/history-coverage.md +50 -0
- package/skills/talking-head-motion-workflow/references/layered-assets-and-characters.md +39 -0
- package/skills/talking-head-motion-workflow/references/layout-references.md +41 -0
- package/skills/talking-head-motion-workflow/references/lens-shot-selection.md +138 -0
- package/skills/talking-head-motion-workflow/references/live-interface-motion.md +69 -0
- package/skills/talking-head-motion-workflow/references/motion-recipes.md +40 -0
- package/skills/talking-head-motion-workflow/references/mouse-meter2-case.md +113 -0
- package/skills/talking-head-motion-workflow/references/pop-collage.md +61 -0
- package/skills/talking-head-motion-workflow/references/portable-production.md +32 -0
- package/skills/talking-head-motion-workflow/references/production-requirements.md +85 -0
- package/skills/talking-head-motion-workflow/references/reference-library.md +41 -0
- package/skills/talking-head-motion-workflow/references/safe-areas-and-sound.md +47 -0
- package/skills/talking-head-motion-workflow/references/scene-illustrations.md +19 -0
- package/skills/talking-head-motion-workflow/references/sfx-presets.md +57 -0
- package/skills/talking-head-motion-workflow/references/style-13-github-production.md +33 -0
- package/skills/talking-head-motion-workflow/references/style-13-scene-performance.md +76 -0
- package/skills/talking-head-motion-workflow/references/style-presets.md +111 -0
- package/skills/talking-head-motion-workflow/references/table-video-spatial-mg.md +36 -0
- package/skills/talking-head-motion-workflow/scripts/extract_docx.py +19 -0
- package/skills/talking-head-motion-workflow/scripts/generate_foley.py +93 -0
- package/skills/talking-head-motion-workflow/scripts/render_sfx.py +135 -0
- package/skills/video-production-review/SKILL.md +30 -0
- package/skills/video-production-review/agents/openai.yaml +2 -0
- package/skills/video-production-review/references/episode-review-desk.md +30 -0
- package/skills/video-production-review/references/motion-adjustment-review.md +21 -0
- package/skills/video-production-workflow/SKILL.md +76 -0
- package/skills/video-production-workflow/agents/openai.yaml +2 -0
- package/skills/video-production-workflow/references/table-video-ep09.md +17 -0
- package/skills/video-production-workflow/scripts/check_motion_project.py +83 -0
- package/skills/video-reference-analysis/SKILL.md +32 -0
- package/skills/video-reference-analysis/agents/openai.yaml +2 -0
- package/skills/video-reference-analysis/references/case-format.md +95 -0
- package/skills/video-reference-analysis/references/production-method.md +21 -0
- package/skills/video-reference-analysis/scripts/library.py +371 -0
- package/skills/video-resource-access/SKILL.md +35 -0
- package/skills/video-resource-access/online.enabled +1 -0
- package/skills/video-resource-access/scripts/asset_client.py +159 -0
- package/skills/video-resource-access/scripts/remote_library.py +50 -0
- package//345/256/211/350/243/205/350/257/264/346/230/216.txt +5 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Generate raw transcript files from a finished/cut video.
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# generate_srt_for_video.sh <video.mp4> <subtitle_output_dir>
|
|
7
|
+
#
|
|
8
|
+
# Output:
|
|
9
|
+
# <subtitle_output_dir>/1_转录/audio.mp3
|
|
10
|
+
# <subtitle_output_dir>/1_转录/volcengine_result.json
|
|
11
|
+
# <subtitle_output_dir>/subtitles_with_time.json
|
|
12
|
+
# <subtitle_output_dir>/3_输出/video.raw.srt
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
|
|
17
|
+
VIDEO_PATH="${1:-}"
|
|
18
|
+
OUTPUT_DIR="${2:-}"
|
|
19
|
+
|
|
20
|
+
if [ -z "$VIDEO_PATH" ] || [ -z "$OUTPUT_DIR" ]; then
|
|
21
|
+
echo "用法: generate_srt_for_video.sh <video.mp4> <subtitle_output_dir>" >&2
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
if [ ! -f "$VIDEO_PATH" ]; then
|
|
26
|
+
echo "找不到视频文件: $VIDEO_PATH" >&2
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
31
|
+
TRANSCRIBE_SCRIPT="$SCRIPT_DIR/volcengine_transcribe.sh"
|
|
32
|
+
|
|
33
|
+
mkdir -p "$OUTPUT_DIR/1_转录" "$OUTPUT_DIR/3_输出"
|
|
34
|
+
|
|
35
|
+
cd "$OUTPUT_DIR/1_转录"
|
|
36
|
+
|
|
37
|
+
echo "🎧 提取剪后视频音频..."
|
|
38
|
+
ffmpeg -y -v error -i "file:$VIDEO_PATH" -vn -acodec libmp3lame audio.mp3
|
|
39
|
+
|
|
40
|
+
echo "🎤 调用火山引擎录音文件识别 2.0..."
|
|
41
|
+
bash "$TRANSCRIBE_SCRIPT" audio.mp3
|
|
42
|
+
|
|
43
|
+
node - <<'NODE'
|
|
44
|
+
const fs = require('fs');
|
|
45
|
+
const result = JSON.parse(fs.readFileSync('volcengine_result.json', 'utf8'));
|
|
46
|
+
const utterances = result.utterances || result.result?.utterances || [];
|
|
47
|
+
|
|
48
|
+
const subtitles = utterances.map((u, i) => ({
|
|
49
|
+
id: i + 1,
|
|
50
|
+
text: u.text || '',
|
|
51
|
+
start: (u.start_time ?? u.start ?? 0) / 1000,
|
|
52
|
+
end: (u.end_time ?? u.end ?? 0) / 1000
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
fs.writeFileSync('../subtitles_with_time.json', JSON.stringify(subtitles, null, 2));
|
|
56
|
+
|
|
57
|
+
function toSRT(sec) {
|
|
58
|
+
const h = Math.floor(sec / 3600);
|
|
59
|
+
const m = Math.floor((sec % 3600) / 60);
|
|
60
|
+
const s = Math.floor(sec % 60);
|
|
61
|
+
const ms = Math.round((sec % 1) * 1000);
|
|
62
|
+
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')},${String(ms).padStart(3, '0')}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const srt = subtitles.map((item, i) => {
|
|
66
|
+
const text = item.text.replace(/[。!?]+$/g, '');
|
|
67
|
+
return `${i + 1}\n${toSRT(item.start)} --> ${toSRT(item.end)}\n${text}`;
|
|
68
|
+
}).join('\n\n');
|
|
69
|
+
|
|
70
|
+
fs.writeFileSync('../3_输出/video.raw.srt', srt.trim() + '\n');
|
|
71
|
+
console.log(`✅ 已生成 ${subtitles.length} 条转写初稿: ../3_输出/video.raw.srt`);
|
|
72
|
+
NODE
|
|
73
|
+
|
|
74
|
+
echo "✅ Raw SRT: $OUTPUT_DIR/3_输出/video.raw.srt"
|
|
75
|
+
echo "下一步:Agent 读取转写初稿,对照原稿/正文做 AI 校对后,再写入 $OUTPUT_DIR/3_输出/video.srt"
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 从火山引擎结果生成字级别字幕
|
|
4
|
+
*
|
|
5
|
+
* 用法: node generate_subtitles.js <volcengine_result.json> [delete_segments.json]
|
|
6
|
+
* 输出: subtitles_words.json
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
|
|
11
|
+
const resultFile = process.argv[2] || 'volcengine_result.json';
|
|
12
|
+
const deleteFile = process.argv[3];
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(resultFile)) {
|
|
15
|
+
console.error('❌ 找不到文件:', resultFile);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const result = JSON.parse(fs.readFileSync(resultFile, 'utf8'));
|
|
20
|
+
|
|
21
|
+
const utterances = result.utterances || result.result?.utterances || [];
|
|
22
|
+
|
|
23
|
+
if (!Array.isArray(utterances) || utterances.length === 0) {
|
|
24
|
+
console.error('❌ 转录结果里没有 utterances');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 提取所有字/词。v3 Seed ASR 2.0 会返回少量空格 token,时间戳为 -1;这些不能进入剪辑时间轴。
|
|
29
|
+
const allWords = [];
|
|
30
|
+
let skippedInvalidWords = 0;
|
|
31
|
+
for (const utterance of utterances) {
|
|
32
|
+
if (utterance.words) {
|
|
33
|
+
for (const word of utterance.words) {
|
|
34
|
+
const text = String(word.text || '').trim();
|
|
35
|
+
const startTime = Number(word.start_time);
|
|
36
|
+
const endTime = Number(word.end_time);
|
|
37
|
+
if (!text || startTime < 0 || endTime < 0) {
|
|
38
|
+
skippedInvalidWords += 1;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
allWords.push({
|
|
42
|
+
text,
|
|
43
|
+
start: startTime / 1000,
|
|
44
|
+
end: endTime / 1000
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log('原始字数:', allWords.length);
|
|
51
|
+
if (skippedInvalidWords > 0) {
|
|
52
|
+
console.log('已过滤无效时间戳 token:', skippedInvalidWords);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 如果有删除片段,映射时间
|
|
56
|
+
let outputWords = allWords;
|
|
57
|
+
|
|
58
|
+
if (deleteFile && fs.existsSync(deleteFile)) {
|
|
59
|
+
const deleteSegments = JSON.parse(fs.readFileSync(deleteFile, 'utf8'));
|
|
60
|
+
console.log('删除片段数:', deleteSegments.length);
|
|
61
|
+
|
|
62
|
+
function getDeletedTimeBefore(time) {
|
|
63
|
+
let deleted = 0;
|
|
64
|
+
for (const seg of deleteSegments) {
|
|
65
|
+
if (seg.end <= time) {
|
|
66
|
+
deleted += seg.end - seg.start;
|
|
67
|
+
} else if (seg.start < time) {
|
|
68
|
+
deleted += time - seg.start;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return deleted;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isDeleted(start, end) {
|
|
75
|
+
for (const seg of deleteSegments) {
|
|
76
|
+
if (start < seg.end && end > seg.start) return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
outputWords = [];
|
|
82
|
+
for (const word of allWords) {
|
|
83
|
+
if (!isDeleted(word.start, word.end)) {
|
|
84
|
+
const deletedBefore = getDeletedTimeBefore(word.start);
|
|
85
|
+
outputWords.push({
|
|
86
|
+
text: word.text,
|
|
87
|
+
start: Math.round((word.start - deletedBefore) * 100) / 100,
|
|
88
|
+
end: Math.round((word.end - deletedBefore) * 100) / 100
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
console.log('映射后字数:', outputWords.length);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 添加空白标记(>0.5秒的静音按1秒拆分,便于精细控制)
|
|
96
|
+
const wordsWithGaps = [];
|
|
97
|
+
let lastEnd = 0;
|
|
98
|
+
|
|
99
|
+
for (const word of outputWords) {
|
|
100
|
+
const gapDuration = word.start - lastEnd;
|
|
101
|
+
|
|
102
|
+
if (gapDuration > 0.1) {
|
|
103
|
+
// 如果静音 >0.5秒,按1秒拆分
|
|
104
|
+
if (gapDuration > 0.5) {
|
|
105
|
+
let gapStart = lastEnd;
|
|
106
|
+
while (gapStart < word.start) {
|
|
107
|
+
const gapEnd = Math.min(gapStart + 1, word.start);
|
|
108
|
+
wordsWithGaps.push({
|
|
109
|
+
text: '',
|
|
110
|
+
start: Math.round(gapStart * 100) / 100,
|
|
111
|
+
end: Math.round(gapEnd * 100) / 100,
|
|
112
|
+
isGap: true
|
|
113
|
+
});
|
|
114
|
+
gapStart = gapEnd;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
// <1秒的静音保持原样
|
|
118
|
+
wordsWithGaps.push({
|
|
119
|
+
text: '',
|
|
120
|
+
start: Math.round(lastEnd * 100) / 100,
|
|
121
|
+
end: Math.round(word.start * 100) / 100,
|
|
122
|
+
isGap: true
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
wordsWithGaps.push({
|
|
128
|
+
text: word.text,
|
|
129
|
+
start: word.start,
|
|
130
|
+
end: word.end,
|
|
131
|
+
isGap: false
|
|
132
|
+
});
|
|
133
|
+
lastEnd = word.end;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const gaps = wordsWithGaps.filter(w => w.isGap);
|
|
137
|
+
console.log('总元素数:', wordsWithGaps.length);
|
|
138
|
+
console.log('空白段数:', gaps.length);
|
|
139
|
+
|
|
140
|
+
fs.writeFileSync('subtitles_words.json', JSON.stringify(wordsWithGaps, null, 2));
|
|
141
|
+
console.log('✅ 已保存 subtitles_words.json');
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 审核服务器
|
|
4
|
+
*
|
|
5
|
+
* 功能:
|
|
6
|
+
* 1. 提供静态文件服务(review.html, video.mp4)
|
|
7
|
+
* 2. POST /api/cut - 接收删除列表,执行剪辑
|
|
8
|
+
*
|
|
9
|
+
* 用法: node review_server.js [port] [video_file]
|
|
10
|
+
* 默认: port=8899, video_file=自动检测目录下的 .mp4
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const http = require('http');
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const { execSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const PORT = process.argv[2] || 8899;
|
|
19
|
+
let VIDEO_FILE = process.argv[3] || findVideoFile();
|
|
20
|
+
|
|
21
|
+
function findVideoFile() {
|
|
22
|
+
const files = fs.readdirSync('.').filter(f => f.endsWith('.mp4'));
|
|
23
|
+
return files[0] || 'source.mp4';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const MIME_TYPES = {
|
|
27
|
+
'.html': 'text/html',
|
|
28
|
+
'.js': 'application/javascript',
|
|
29
|
+
'.css': 'text/css',
|
|
30
|
+
'.json': 'application/json',
|
|
31
|
+
'.mp3': 'audio/mpeg',
|
|
32
|
+
'.mp4': 'video/mp4',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const server = http.createServer((req, res) => {
|
|
36
|
+
// CORS
|
|
37
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
38
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
39
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
40
|
+
|
|
41
|
+
if (req.method === 'OPTIONS') {
|
|
42
|
+
res.writeHead(200);
|
|
43
|
+
res.end();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// API: 保存选中状态
|
|
48
|
+
if (req.method === 'POST' && req.url === '/api/save-selection') {
|
|
49
|
+
let body = '';
|
|
50
|
+
req.on('data', chunk => body += chunk);
|
|
51
|
+
req.on('end', () => {
|
|
52
|
+
try {
|
|
53
|
+
fs.writeFileSync('saved_selection.json', body);
|
|
54
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
55
|
+
res.end(JSON.stringify({ success: true }));
|
|
56
|
+
} catch (e) {
|
|
57
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
58
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// API: 读取选中状态
|
|
65
|
+
if (req.method === 'GET' && req.url === '/api/load-selection') {
|
|
66
|
+
try {
|
|
67
|
+
if (fs.existsSync('saved_selection.json')) {
|
|
68
|
+
const data = fs.readFileSync('saved_selection.json', 'utf8');
|
|
69
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
70
|
+
res.end(data);
|
|
71
|
+
} else {
|
|
72
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
73
|
+
res.end(JSON.stringify({ error: 'no saved selection' }));
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
77
|
+
res.end(JSON.stringify({ error: e.message }));
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// API: 执行剪辑
|
|
83
|
+
if (req.method === 'POST' && req.url === '/api/cut') {
|
|
84
|
+
let body = '';
|
|
85
|
+
req.on('data', chunk => body += chunk);
|
|
86
|
+
req.on('end', () => {
|
|
87
|
+
try {
|
|
88
|
+
const deleteList = JSON.parse(body);
|
|
89
|
+
|
|
90
|
+
// 保存删除列表到当前目录
|
|
91
|
+
fs.writeFileSync('delete_segments.json', JSON.stringify(deleteList, null, 2));
|
|
92
|
+
console.log(`📝 保存 ${deleteList.length} 个删除片段`);
|
|
93
|
+
|
|
94
|
+
// 生成输出文件名
|
|
95
|
+
const baseName = path.basename(VIDEO_FILE, '.mp4');
|
|
96
|
+
const outputFile = `${baseName}_cut.mp4`;
|
|
97
|
+
|
|
98
|
+
// 执行剪辑
|
|
99
|
+
const scriptPath = path.join(__dirname, 'cut_video.sh');
|
|
100
|
+
|
|
101
|
+
if (!fs.existsSync(scriptPath)) {
|
|
102
|
+
// 如果没有 cut_video.sh,用内置的 ffmpeg 命令
|
|
103
|
+
console.log('🎬 执行剪辑...');
|
|
104
|
+
executeFFmpegCut(VIDEO_FILE, deleteList, outputFile);
|
|
105
|
+
} else {
|
|
106
|
+
console.log('🎬 调用 cut_video.sh...');
|
|
107
|
+
execSync(`bash "${scriptPath}" "${VIDEO_FILE}" delete_segments.json "${outputFile}"`, {
|
|
108
|
+
stdio: 'inherit'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 获取剪辑前后的时长信息
|
|
113
|
+
const outputPath = path.resolve(outputFile);
|
|
114
|
+
const originalDuration = parseFloat(execSync(`ffprobe -v error -show_entries format=duration -of csv=p=0 "file:${VIDEO_FILE}"`).toString().trim());
|
|
115
|
+
const newDuration = parseFloat(execSync(`ffprobe -v error -show_entries format=duration -of csv=p=0 "file:${outputPath}"`).toString().trim());
|
|
116
|
+
const deletedDuration = originalDuration - newDuration;
|
|
117
|
+
const savedPercent = ((deletedDuration / originalDuration) * 100).toFixed(1);
|
|
118
|
+
const cutDone = {
|
|
119
|
+
success: true,
|
|
120
|
+
output: outputPath,
|
|
121
|
+
originalDuration: originalDuration.toFixed(2),
|
|
122
|
+
newDuration: newDuration.toFixed(2),
|
|
123
|
+
deletedDuration: deletedDuration.toFixed(2),
|
|
124
|
+
savedPercent: savedPercent,
|
|
125
|
+
completedAt: new Date().toISOString(),
|
|
126
|
+
nextStep: 'Agent 基于剪后视频重新转写,AI 校对后再写入最终 subtitles.srt。'
|
|
127
|
+
};
|
|
128
|
+
fs.writeFileSync('cut_done.json', JSON.stringify(cutDone, null, 2));
|
|
129
|
+
|
|
130
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
131
|
+
res.end(JSON.stringify({ ...cutDone, message: `剪辑完成: ${outputPath}` }));
|
|
132
|
+
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.error('❌ 剪辑失败:', err.message);
|
|
135
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
136
|
+
res.end(JSON.stringify({ success: false, error: err.message }));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 静态文件服务(从当前目录读取)
|
|
143
|
+
let filePath = req.url === '/' ? '/review.html' : req.url;
|
|
144
|
+
filePath = '.' + filePath;
|
|
145
|
+
|
|
146
|
+
const ext = path.extname(filePath);
|
|
147
|
+
const contentType = MIME_TYPES[ext] || 'application/octet-stream';
|
|
148
|
+
|
|
149
|
+
// 检查文件是否存在
|
|
150
|
+
if (!fs.existsSync(filePath)) {
|
|
151
|
+
res.writeHead(404);
|
|
152
|
+
res.end('Not Found');
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const stat = fs.statSync(filePath);
|
|
157
|
+
|
|
158
|
+
// 支持 Range 请求(音频/视频拖动)
|
|
159
|
+
if (req.headers.range && (ext === '.mp3' || ext === '.mp4')) {
|
|
160
|
+
const range = req.headers.range.replace('bytes=', '').split('-');
|
|
161
|
+
const start = parseInt(range[0], 10);
|
|
162
|
+
const end = range[1] ? parseInt(range[1], 10) : stat.size - 1;
|
|
163
|
+
|
|
164
|
+
res.writeHead(206, {
|
|
165
|
+
'Content-Type': contentType,
|
|
166
|
+
'Content-Range': `bytes ${start}-${end}/${stat.size}`,
|
|
167
|
+
'Accept-Ranges': 'bytes',
|
|
168
|
+
'Content-Length': end - start + 1,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
fs.createReadStream(filePath, { start, end }).pipe(res);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 普通请求
|
|
176
|
+
res.writeHead(200, {
|
|
177
|
+
'Content-Type': contentType,
|
|
178
|
+
'Content-Length': stat.size,
|
|
179
|
+
'Accept-Ranges': 'bytes'
|
|
180
|
+
});
|
|
181
|
+
fs.createReadStream(filePath).pipe(res);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// 检测可用的硬件编码器
|
|
185
|
+
function detectEncoder() {
|
|
186
|
+
const platform = process.platform;
|
|
187
|
+
const encoders = [];
|
|
188
|
+
|
|
189
|
+
// 根据平台确定候选编码器
|
|
190
|
+
if (platform === 'darwin') {
|
|
191
|
+
encoders.push({ name: 'h264_videotoolbox', args: '-q:v 60', label: 'VideoToolbox (macOS)' });
|
|
192
|
+
} else if (platform === 'win32') {
|
|
193
|
+
encoders.push({ name: 'h264_nvenc', args: '-preset p4 -cq 20', label: 'NVENC (NVIDIA)' });
|
|
194
|
+
encoders.push({ name: 'h264_qsv', args: '-global_quality 20', label: 'QSV (Intel)' });
|
|
195
|
+
encoders.push({ name: 'h264_amf', args: '-quality balanced', label: 'AMF (AMD)' });
|
|
196
|
+
} else {
|
|
197
|
+
// Linux
|
|
198
|
+
encoders.push({ name: 'h264_nvenc', args: '-preset p4 -cq 20', label: 'NVENC (NVIDIA)' });
|
|
199
|
+
encoders.push({ name: 'h264_vaapi', args: '-qp 20', label: 'VAAPI (Linux)' });
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 软件编码兜底
|
|
203
|
+
encoders.push({ name: 'libx264', args: '-preset fast -crf 18', label: 'x264 (软件)' });
|
|
204
|
+
|
|
205
|
+
// 检测哪个可用
|
|
206
|
+
for (const enc of encoders) {
|
|
207
|
+
try {
|
|
208
|
+
execSync(`ffmpeg -hide_banner -encoders 2>/dev/null | grep ${enc.name}`, { stdio: 'pipe' });
|
|
209
|
+
console.log(`🎯 检测到编码器: ${enc.label}`);
|
|
210
|
+
return enc;
|
|
211
|
+
} catch (e) {
|
|
212
|
+
// 该编码器不可用,继续检测下一个
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 默认返回软件编码
|
|
217
|
+
return { name: 'libx264', args: '-preset fast -crf 18', label: 'x264 (软件)' };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 缓存编码器检测结果
|
|
221
|
+
let cachedEncoder = null;
|
|
222
|
+
function getEncoder() {
|
|
223
|
+
if (!cachedEncoder) {
|
|
224
|
+
cachedEncoder = detectEncoder();
|
|
225
|
+
}
|
|
226
|
+
return cachedEncoder;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 内置 FFmpeg 剪辑逻辑(filter_complex 精确剪辑 + buffer + crossfade)
|
|
230
|
+
function executeFFmpegCut(input, deleteList, output) {
|
|
231
|
+
// 配置参数
|
|
232
|
+
const BUFFER_MS = 120; // 删除范围前后各扩展 120ms(吃掉尾音和气口)
|
|
233
|
+
const CROSSFADE_MS = 30; // 音频淡入淡出 30ms
|
|
234
|
+
|
|
235
|
+
console.log(`⚙️ 优化参数: 扩展范围=${BUFFER_MS}ms, 音频crossfade=${CROSSFADE_MS}ms`);
|
|
236
|
+
|
|
237
|
+
// 检测音频偏移量(MP3编码引入的延迟)
|
|
238
|
+
let audioOffset = 0;
|
|
239
|
+
const audioPath = path.resolve(path.dirname(path.dirname(process.cwd())), '1_转录', 'audio.mp3');
|
|
240
|
+
if (fs.existsSync(audioPath)) {
|
|
241
|
+
try {
|
|
242
|
+
audioOffset = parseFloat(execSync(`ffprobe -v error -show_entries format=start_time -of csv=p=0 "${audioPath}"`).toString().trim()) || 0;
|
|
243
|
+
if (audioOffset > 0) {
|
|
244
|
+
console.log(`🔧 检测到音频偏移: ${audioOffset.toFixed(3)}s,自动补偿`);
|
|
245
|
+
}
|
|
246
|
+
} catch (e) { /* 忽略 */ }
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// 获取视频总时长
|
|
250
|
+
const probeCmd = `ffprobe -v error -show_entries format=duration -of csv=p=0 "file:${input}"`;
|
|
251
|
+
const duration = parseFloat(execSync(probeCmd).toString().trim());
|
|
252
|
+
|
|
253
|
+
const bufferSec = BUFFER_MS / 1000;
|
|
254
|
+
const crossfadeSec = CROSSFADE_MS / 1000;
|
|
255
|
+
|
|
256
|
+
// 不扩展删除范围,使用精确边界(防止吃掉相邻保留字的头尾音)
|
|
257
|
+
const expandedDelete = deleteList
|
|
258
|
+
.map(seg => ({
|
|
259
|
+
start: Math.max(0, seg.start - audioOffset),
|
|
260
|
+
end: Math.min(duration, seg.end - audioOffset)
|
|
261
|
+
}))
|
|
262
|
+
.sort((a, b) => a.start - b.start);
|
|
263
|
+
|
|
264
|
+
// 合并重叠 + 间隙小于 200ms 的相邻删除段(避免产生无意义碎片)
|
|
265
|
+
const MERGE_GAP = 0.2;
|
|
266
|
+
const mergedDelete = [];
|
|
267
|
+
for (const seg of expandedDelete) {
|
|
268
|
+
if (mergedDelete.length === 0 || seg.start > mergedDelete[mergedDelete.length - 1].end + MERGE_GAP) {
|
|
269
|
+
mergedDelete.push({ ...seg });
|
|
270
|
+
} else {
|
|
271
|
+
mergedDelete[mergedDelete.length - 1].end = Math.max(mergedDelete[mergedDelete.length - 1].end, seg.end);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// 计算保留片段
|
|
276
|
+
const keepSegments = [];
|
|
277
|
+
let cursor = 0;
|
|
278
|
+
|
|
279
|
+
for (const del of mergedDelete) {
|
|
280
|
+
if (del.start > cursor) {
|
|
281
|
+
keepSegments.push({ start: cursor, end: del.start });
|
|
282
|
+
}
|
|
283
|
+
cursor = del.end;
|
|
284
|
+
}
|
|
285
|
+
if (cursor < duration) {
|
|
286
|
+
keepSegments.push({ start: cursor, end: duration });
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
console.log(`保留 ${keepSegments.length} 个片段,删除 ${mergedDelete.length} 个片段`);
|
|
290
|
+
|
|
291
|
+
// 生成 filter_complex(带 crossfade)
|
|
292
|
+
let filters = [];
|
|
293
|
+
let vconcat = '';
|
|
294
|
+
|
|
295
|
+
for (let i = 0; i < keepSegments.length; i++) {
|
|
296
|
+
const seg = keepSegments[i];
|
|
297
|
+
filters.push(`[0:v]trim=start=${seg.start.toFixed(3)}:end=${seg.end.toFixed(3)},setpts=PTS-STARTPTS[v${i}]`);
|
|
298
|
+
filters.push(`[0:a]atrim=start=${seg.start.toFixed(3)}:end=${seg.end.toFixed(3)},asetpts=PTS-STARTPTS[a${i}]`);
|
|
299
|
+
vconcat += `[v${i}]`;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// 视频直接 concat
|
|
303
|
+
filters.push(`${vconcat}concat=n=${keepSegments.length}:v=1:a=0[outv]`);
|
|
304
|
+
|
|
305
|
+
// 音频使用 acrossfade 逐个拼接(消除接缝咔声)
|
|
306
|
+
if (keepSegments.length === 1) {
|
|
307
|
+
filters.push(`[a0]anull[outa]`);
|
|
308
|
+
} else {
|
|
309
|
+
let currentLabel = 'a0';
|
|
310
|
+
for (let i = 1; i < keepSegments.length; i++) {
|
|
311
|
+
const nextLabel = `a${i}`;
|
|
312
|
+
const outLabel = (i === keepSegments.length - 1) ? 'outa' : `amid${i}`;
|
|
313
|
+
filters.push(`[${currentLabel}][${nextLabel}]acrossfade=d=${crossfadeSec.toFixed(3)}:c1=tri:c2=tri[${outLabel}]`);
|
|
314
|
+
currentLabel = outLabel;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const filterComplex = filters.join(';');
|
|
319
|
+
|
|
320
|
+
const encoder = getEncoder();
|
|
321
|
+
console.log(`✂️ 执行 FFmpeg 精确剪辑(${encoder.label})...`);
|
|
322
|
+
|
|
323
|
+
const cmd = `ffmpeg -y -i "file:${input}" -filter_complex "${filterComplex}" -map "[outv]" -map "[outa]" -c:v ${encoder.name} ${encoder.args} -c:a aac -b:a 192k "file:${output}"`;
|
|
324
|
+
|
|
325
|
+
try {
|
|
326
|
+
execSync(cmd, { stdio: 'pipe' });
|
|
327
|
+
console.log(`✅ 输出: ${output}`);
|
|
328
|
+
|
|
329
|
+
const newDuration = parseFloat(execSync(`ffprobe -v error -show_entries format=duration -of csv=p=0 "file:${output}"`).toString().trim());
|
|
330
|
+
console.log(`📹 新时长: ${newDuration.toFixed(2)}s`);
|
|
331
|
+
} catch (err) {
|
|
332
|
+
console.error('FFmpeg 执行失败,尝试分段方案...');
|
|
333
|
+
executeFFmpegCutFallback(input, keepSegments, output);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// 备用方案:分段切割 + concat(当 filter_complex 失败时使用)
|
|
338
|
+
function executeFFmpegCutFallback(input, keepSegments, output) {
|
|
339
|
+
const tmpDir = `tmp_cut_${Date.now()}`;
|
|
340
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
const partFiles = [];
|
|
344
|
+
keepSegments.forEach((seg, i) => {
|
|
345
|
+
const partFile = path.join(tmpDir, `part${i.toString().padStart(4, '0')}.mp4`);
|
|
346
|
+
const segDuration = seg.end - seg.start;
|
|
347
|
+
|
|
348
|
+
const encoder = getEncoder();
|
|
349
|
+
const cmd = `ffmpeg -y -ss ${seg.start.toFixed(3)} -i "file:${input}" -t ${segDuration.toFixed(3)} -c:v ${encoder.name} ${encoder.args} -c:a aac -b:a 128k -avoid_negative_ts make_zero "${partFile}"`;
|
|
350
|
+
|
|
351
|
+
console.log(`切割片段 ${i + 1}/${keepSegments.length}: ${seg.start.toFixed(2)}s - ${seg.end.toFixed(2)}s`);
|
|
352
|
+
execSync(cmd, { stdio: 'pipe' });
|
|
353
|
+
partFiles.push(partFile);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
const listFile = path.join(tmpDir, 'list.txt');
|
|
357
|
+
const listContent = partFiles.map(f => `file '${path.resolve(f)}'`).join('\n');
|
|
358
|
+
fs.writeFileSync(listFile, listContent);
|
|
359
|
+
|
|
360
|
+
const concatCmd = `ffmpeg -y -f concat -safe 0 -i "${listFile}" -c copy "${output}"`;
|
|
361
|
+
console.log('合并片段...');
|
|
362
|
+
execSync(concatCmd, { stdio: 'pipe' });
|
|
363
|
+
|
|
364
|
+
console.log(`✅ 输出: ${output}`);
|
|
365
|
+
} finally {
|
|
366
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
server.listen(PORT, () => {
|
|
371
|
+
console.log(`
|
|
372
|
+
🎬 审核服务器已启动
|
|
373
|
+
📍 地址: http://localhost:${PORT}
|
|
374
|
+
📹 视频: ${VIDEO_FILE}
|
|
375
|
+
|
|
376
|
+
操作说明:
|
|
377
|
+
1. 在网页中审核选择要删除的片段
|
|
378
|
+
2. 点击「🎬 执行剪辑」按钮
|
|
379
|
+
3. 等待剪辑完成
|
|
380
|
+
`);
|
|
381
|
+
});
|