ffmpeg叠加的图片是一个黑色矩形。

huangapple go评论50阅读模式
英文:

ffmpeg overlay picture is a black rectangle

问题

I'm trying to overlay several images over an existing video, with the first image coming in with a fade-in effect. But instead I'm getting a black rectangle in place of the picture. But if I skip the fade-in and just put [img0] after decrease like so decrease[img0] then it works (but without fade in)

英文:

I'm trying to overlay several images over an existing video, with the first image coming in with a fade-in effect. But instead I'm getting a black rectangle in place of the picture. But if I skip the fade-in and just put [img0] after decrease like so decrease[img0] then it works (but without fade in)

please advise. TY

-y
-i "G:\...\Videos\BLANK.mp4" 
-i "G:\...\Front.jpg" 
-i "G:\...\Front.jpg" 
-i "G:\...\Front.jpg" 
-i "G:\...\Front.jpg" 
-i "G:\...\Front.jpg" 
-i "G:\...\Front.jpg" 

-filter_complex [1:v]scale=880:545:force_original_aspect_ratio=decrease,fade=t=in:st=2.6:d=1[img0];
[0:v][img0]overlay=x='if(lte(2.6-t,0),450,NAN)':y='if(lte(2.6-t,0),5,NAN)':enable='between(t,2.6,4)'[v0];
[2:v]scale=880:545:force_original_aspect_ratio=decrease[img1];
[v0][img1]overlay=x='if(lte(4-t,0),450,NAN)':y='if(lte(4-t,0),5,NAN)':enable='between(t,4,5.6)'[v1];
[3:v]scale=880:545:force_original_aspect_ratio=decrease[img2];
[v1][img2]overlay=x='if(lte(5.6-t,0),450,NAN)':y='if(lte(5.6-t,0),5,NAN)':enable='between(t,5.6,6.3)'[v2];
[4:v]scale=880:545:force_original_aspect_ratio=decrease[img3];
[v2][img3]overlay=x='if(lte(6.3-t,0),450,NAN)':y='if(lte(6.3-t,0),5,NAN)':enable='between(t,6.3,6.9)'[v3];
[5:v]scale=880:545:force_original_aspect_ratio=decrease[img4];
[v3][img4]overlay=x='if(lte(6.9-t,0),450,NAN)':y='if(lte(6.9-t,0),5,NAN)':enable='between(t,6.9,7.4)'[v4];
[6:v]scale=880:545:force_original_aspect_ratio=decrease[img5];
[v4][img5]overlay=x='if(lte(7.4-t,0),450,NAN)':y='if(lte(7.4-t,0),5,NAN)':enable='between(t,7.4,7.9)'[v5];

 -map [v5] -map 0:a -c:v libx264 -c:a copy "G:\...\Videos\ffmpeg\output.mp4"

答案1

得分: 1

  1. 单个图像文件代表一个只有1帧的视频流,而淡入效果需要一系列帧才能实现动画效果。

  2. 默认情况下,淡入会改变输入的颜色。而您需要对透明度(称为 alpha)进行动画处理。JPEG 图像本身不包含 alpha 通道,因此我们需要添加 alpha 通道,然后告诉淡入效果处理 alpha 通道。

因此,在 "-i "G:...\Front\1.jpg"" 之前添加 -loop 1 -t 3.6,其中 3.6 是淡入效果完成的时间。

然后,初始滤镜将如下所示:

[1:v]format=yuva444p,scale=880:545:force_original_aspect_ratio=decrease,fade=t=in:st=2.6:d=1:alpha=1[img0];

英文:

Multiple issues prevent your command from resulting in that outcome.

  1. A single image file represents a video stream of 1 frame whereas fade requires a sequence of frames for the animation to occur.

  2. Fade, by default, alters the color of the input. Whereas you need to animate the transparency (known as the alpha). JPEGs don't come with these, so we need to add alpha. And then tell fade to work on the alpha.

So add -loop 1 -t 3.6 before -i "G:\...\Front\1.jpg" where 3.6 is the time for fade in to complete.

Then the initial filter will be,

[1:v]format=yuva444p,scale=880:545:force_original_aspect_ratio=decrease,fade=t=in:st=2.6:d=1:alpha=1[img0];

huangapple
  • 本文由 发表于 2023年6月6日 08:23:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76410720.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定