2

这是我想用 fluent-ffmpeg 做的事情:

我有 3 个输入文件。介绍、主要和结尾视频。我希望合并这三个,同时修剪主视频。这是我的代码:

var ffmpegCommand = ffmpeg();
ffmpegCommand.addInput(introVideo);
ffmpegCommand.addInput(mainVideo).seekInput(20).duration(3);
ffmpegCommand.addInput(outroVideo);
ffmpegCommand.on('error', function(err, stdout, stderr){
  console.log("FAILED!\n\t"+err+"\n\t"+stdout+"\n\t"+stderr);
});
ffmpegCommand.on('end', function(){
  console.log('COMPLETE!');
});
ffmpegCommand.on('start', function(commandLine) {
  console.log('Spawned Ffmpeg with command: ' + commandLine);
});
ffmpegCommand.mergeToFile('final.mp4', './vid_files/tmp');

该程序执行得很好,但是当我 ffplay final.mp4 时,结果是 introVideo 播放然后视频似乎冻结了。根据 fluent-ffmpeg 文档,它声明“这些 [输入选项] 方法中的每一个都适用于添加的最后一个输入”。所以我不明白为什么这种语法似乎不起作用......

如何修剪主视频以发送到 mergeToFile?

请注意,如果我在第二个 addInput 上没有 .seekinput(20).duration(3),这可以正常工作。

哦,这是输出的命令行值:

ffmpeg -i ./vid_files/intro.mp4 -ss 20 -i ./vid_files/main.mp4 -i ./vid_files/outro.mp4 -y -filter_complex concat=n=3:v=1:a=1 -t 3 final.mp4
4

0 回答 0