我正在使用 Fluent-ffmpeg
Node.js 库对视频文件执行批量操作。视频过滤器裁剪 16:9 输入、添加填充并将字幕刻录到填充中。
在下一步中,我想使用复杂的过滤器来覆盖图像作为水印。
ff.input(video.mp4)
ff.input(watermark.png)
ff.videoFilter([
'crop=in_w-2*150:in_h',
'pad=980:980:x=0:y=0:color=black',
'subtitles=subtitles.ass'
])
ff.complexFilter([
'overlay=0:0'
])
ff.output(output.mp4)
但是,运行此程序时,我收到以下错误:
Filtergraph 'crop=in_w-2*150:in_h,pad=980:980:x=0:y=0:color=black,subtitles=subtitles.ass' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a comple.
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.
据我了解,视频过滤器和复杂过滤器选项不能一起使用。如何解决这个问题?
最佳答案
通过学习一些有关过滤器图的基础知识解决了这个问题。这是完整的 ffmpeg 命令。我发现逐行写出过滤字符串更容易阅读。
ffmpeg \
-i video.mp4 \
-i watermark.png \
-filter_complex " \
[0]crop = \
w = in_w-2*150 : \
h = in_h \
[a] ;
[a]pad = \
width = 980 : \
height = 980 : \
x = 0 :
y = 0 :
color = black
[b] ;
[b]subtitles =
filename = subtitles.ass
[c] ;
[c][1]overlay = \
x = 0 :
y = 0
" \
output.mp4
说明:
[0]crop=...[a];
=> 首先将裁剪滤镜应用于视频输入0
。将结果命名为 a
。
[a]pad=...[b];
=> 将 pad 过滤器应用于 a
流。将结果命名为 b
。
[b]subtitles=...[c]
=> 将字幕过滤器应用到 b
流。将结果命名为 c
。
[c][1]overlay...
=> 使用输入 1
(png 文件)应用叠加过滤器来流式传输 c
)。
希望这可以帮助那些在过滤器图表方面遇到困难的人。
关于node.js - FFMPEG:使用具有复杂滤波器的视频滤波器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55455922/