如何在 FFMPEG 中将 blend / tblend 过滤器与 t 变量和 between 语句一起使用

How to use the blend / tblend filter with the t variable and between statement in FFMPEG

我想将 blendtblend 过滤器与 t 变量的 between 语句结合使用。我愿意接受能达到同样效果的其他解决方案。

我知道可以将图像转置到视频上,例如在 00:00:01.00000:00:02.000 之间:

ffmpeg -i input.mkv -i input.jpg -filter_complex \ "[0:v][1:v] overlay=10:10:enable='between(t,1,2)'" output.mkv

可以使用 smartblur:

同时对视频进行模糊处理

ffmpeg -i input.mkv -vf "smartblur=enable='between(t,1,2)'" output.mkv

更改 hue angle,例如90度,也可以做到:

ffmpeg -i input.mkv -vf "hue=h=-90:enable='between(t,1,2)'" output.mkv

然而,我的搜索或官方文档中没有任何内容解释如何使用 blendtblend 过滤器与 t 变量的 [=13] 一起使用来编写命令=] 语句。我试过很多公式,但它们都会导致错误。这根本不可能吗?还是有另一种构造命令的方法?

根据文档中的examples,我们可以将框架乘以评估条件。

示例(输入来自here):

ffmpeg -y -i in.mp4 -i in.gif -filter_complex "[1:v][0:v]scale2ref[v1][v0];[v0][v1]blend=all_expr='A*if(between(T, 2, 6), 0.3, 1)+B*if(between(T, 2, 6), 0.7, 0)'" -vcodec libx264 -pix_fmt yuv444p -crf 17 -acodec copy out.mp4
  • A 应用来自第一个视频流的帧 - [v0].
  • B 应用来自第二个视频流的帧 - [v1].
  • 当时间在 2 到 6 秒之间时,
  • if(between(T, 2, 6), 0.3, 1) 被评估为 0.3,否则评估为 1
  • 当时间在 2 到 6 秒之间时,
  • if(between(T, 2, 6), 0.7, 0) 被计算为 0.7,否则被计算为 0
  • 整个表达式的计算结果为 0.3*A + 0.7*B 介于 2 和 6 之间,否则为 1*A + 0*B

示例输出(2 到 6 秒之间):

注:
我认为确切时间存在错误,但这可能与我的输入有关。


如果需要,我们也可以链接两个 blend 过滤器。
第一次混合应用一些混合效果,第二次混合选择何时使用效果以及何时使用原始视频流。
示例:

ffmpeg -y -i in.mp4 -i in.gif -filter_complex "[1:v][0:v]scale2ref[v1][v0];[v0][v1]blend=all_mode=grainextract[b];[0:v][b]blend=all_expr='A*if(between(T, 2, 6), 0, 1)+B*if(between(T, 2, 6), 1, 0)'" -vcodec libx264 -pix_fmt yuv444p -crf 17 -acodec copy out.mp4

另一种选择是将 blendoverlay 过滤器链接起来。