首页 > 解决方案 > Node fluent ffmpeg:如何添加填充和背景图像?

问题描述

我目前正在使用 npm 包 fluent-ffmpeg:

https://github.com/fluent-ffmpeg/node-fluent-ffmpeg

我想得到这个结果:

在此处输入图像描述

但我不知道该怎么做。
更准确地说,我想调整视频大小和居中,然后添加背景图像。

这是我当前的代码(但不好):

const command = ffmpeg(video_path)
.size('640x480')
.autopad(true, 'pink')
.on('error', function(err) {
    console.log('An error occurred: ' + err.message);
})
.on('end', function() {
    
    console.log('Processing finished !');

    const command2 = ffmpeg(destination_path1)
    .size('1920x1080')
    .applyAutoPadding(true, 'pink')
    .on('error', function(err) {
    console.log('An error occurred: ' + err.message);
    })
    .on('end', function() {
    console.log('Processing finished !');
    })
    .save(destination_path2);

})
.save(destination_path1);

你能帮助我吗?

太感谢了

标签: ffmpegfluent-ffmpeg

解决方案


推荐阅读