Repository navigation
Expand file tree
/
Copy pathtest-ffmpeg.js
More file actions
63 lines (55 loc) · 1.92 KB
/
Copy pathtest-ffmpeg.js
File metadata and controls
63 lines (55 loc) · 1.92 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
// Direct test script for FFmpeg map-reduce generation
const fs = require('fs');
const path = require('path');
const { calculateTasks, generateFFmpegCommand } = require('./scripts/mapreduce-refactor.js');
// 测试配置 - 使用 calculateTasks 期望的格式
const clips = [
{
path: 'temp/BV1AN411c7mR_0.00-60.00.mp4',
start: 0,
end: 5,
title: 'Test Clip 1'
},
{
path: 'temp/BV1AN411c7mR_2.00-62.00.mp4',
start: 2,
end: 7,
title: 'Test Clip 2'
}
];
const settings = {
fadeInDuration: 0.5,
fadeOutDuration: 0.5,
transitionAudioPath: null,
transitionAudioDuration: 0,
tempDir: 'temp',
backgroundPath: 'temp/BV12J4m1x7t1_42.87-97.41.mp4',
encoder: 'h264_nvenc', // 使用GPU加速
encodePreset: 'p4' // NVENC预设: p1(最快) - p7(最慢)
};
const background = {
head: 'temp/BV12J4m1x7t1_42.87-97.41.mp4',
tail: 'temp/BV12J4m1x7t1_42.87-97.41.mp4'
};
console.log('=== Direct FFmpeg Test ===\n');
console.log('Clips:', JSON.stringify(clips, null, 2));
try {
// Step 1: Calculate tasks
console.log('\n--- Step 1: Calculate Tasks ---\n');
const tasks = calculateTasks(clips, settings, background);
console.log('Generated', tasks.length, 'tasks');
console.log('Task 0:', JSON.stringify(tasks[0], null, 2));
// Step 2: Generate FFmpeg command for first task
console.log('\n--- Step 2: Generate FFmpeg Command for Task 0 ---\n');
const command = generateFFmpegCommand(tasks[0], tasks[1]);
console.log('\nGenerated FFmpeg Command:\n');
console.log(command);
console.log('\nCommand length:', command.length, 'characters');
// 保存命令到文件供手动运行
const commandStr = `${command.command} ${command.args.map(a => `"${a}"`).join(' ')}`;
fs.writeFileSync('temp/test-ffmpeg-command.sh', commandStr);
console.log('\n✅ Command saved to: temp/test-ffmpeg-command.sh');
} catch (error) {
console.error('\n❌ Error:', error.message);
console.error(error.stack);
}