“我正在尝试在另一个视频或图像上叠加一个透明的webm,结果是该webm在我想要的位置上,但是背景是黑色。”
我必须使用-vcodec libvpx
,但这是命令行中的内容。
从这里 Overlaying a webm with transparency over an image with FFMpeg
或那里 https://video.stackexchange.com/questions/14959/merge-two-transparent-webm-videos-with-ffmpeg
但是我不知道如何在代码中使用它。
ffmpeg('video.webm')
.input('public/video/trans.webm')
.complexFilter([
"[0:v]scale=1080:1080[video]",
"[1:v]scale=1080:1080[trans]",
"[video][trans]overlay=0:0:enable='between(t,0,3)'[tmp]",
], 'tmp')
.output('edited.mp4')
.videoCodec('libvpx')
.on('progress', function (progress) {
console.log('Processing ' + progress.percent)
})
.on('error', function (err) {
console.log('An error occurred: ' + err.message);
})
.on('end', function () {
let endtime = new Date();
console.log('Finished !');
console.log("Start : " + starttime + " " + starttime.getSeconds() + " " + starttime.getMilliseconds());
console.log("End : " + endtime + " " + endtime.getSeconds() + " " + endtime.getMilliseconds());
console.log("Used : " + Math.abs(starttime - endtime) + " miliseconds");
})
.run();
我确实尝试过使用.videoCodec('libvpx')
然后运行,但是它在下面返回了错误。
An error occurred: ffmpeg exited with code 1: Error initializing complex filters. Invalid argument
视频文件 -video.webm作为背景视频 -trans.webm on video.webm
假设video.webm中有一只猫,而trans.web是一扇打开门的房子,这意味着当门打开时您应该能够看到这只猫。