-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_clips.js
More file actions
66 lines (55 loc) · 1.76 KB
/
check_clips.js
File metadata and controls
66 lines (55 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 检查 clips 数据的有效性
const path = require('path');
console.log('[检查] 模拟 clips 数据验证...\n');
// 模拟可能的问题数据
const testCases = [
{
name: '正常数据',
video: { start: 10, end: 20, duration: 10 }
},
{
name: 'start 和 end 都是 0',
video: { start: 0, end: 0, duration: 10 }
},
{
name: 'end 小于 start',
video: { start: 20, end: 10, duration: 10 }
},
{
name: '缺少 start 和 end',
video: { duration: 10 }
},
{
name: '时长很短(小于淡入+淡出)',
video: { start: 0, end: 0.8, duration: 0.8 }
}
];
testCases.forEach(({ name, video }) => {
console.log(`\n测试用例: ${name}`);
console.log(' 输入:', video);
// 模拟 generator.cjs:2599-2601 的逻辑
const clipStart = video.start || 0;
const clipEnd = video.end ?? video.duration ?? 0;
const clipDuration = Math.max(0, (clipEnd || 0) - clipStart) || (video.duration || 0);
console.log(' 处理后:');
console.log(' clipStart:', clipStart);
console.log(' clipEnd:', clipEnd);
console.log(' clipDuration:', clipDuration);
// 模拟 mapreduce-refactor.js:53 的逻辑
const clipDur = clipEnd - clipStart;
console.log(' Map-Reduce 计算:');
console.log(' clipDur (clip.end - clip.start):', clipDur);
// 模拟 mapreduce-refactor.js:65 的逻辑
const fadeInDuration = 0.5;
const fadeOutDuration = 0.5;
const bodyDur = clipDur - fadeInDuration - fadeOutDuration;
console.log(' bodyDur (clipDur - fadeIn - fadeOut):', bodyDur);
if (bodyDur < 0) {
console.log(' ❌ 负数!这会导致后续计算错误!');
} else if (clipDur === 0) {
console.log(' ❌ clipDur 为 0!');
} else {
console.log(' ✅ 正常');
}
});
console.log('\n[检查] 完成');