ffmpeg complex_filter 中的“不匹配任何流”问题

问题描述 投票:0回答:1

我的目标是使用 ffmpeg complex_filters 来做到这一点:

我有一个 1080 视频背景,喜欢插入一些叠加图形和文本。所以我的输入是 vid 和 2 个 jpg 文件。文件应滑入背景视频上方的位置,同时淡入,停留几秒钟,然后淡出。此外,还应显示文本。

我的主要问题是,它只适用于一个输入 jpg,但是当我添加第二个块时,我在这里遇到了一个错误:

[fc#0 @ 000001bf9d0d0c00] Stream specifier 'merge1C:v' in filtergraph description [1:v]format=pix_fmts=yuva420p,scale=765:1083,fade=in:st=0:d=1:alpha=1 [overlay1A], [0:v][overlay1A] overlay=x='if(lte(-w+(t)*1065,300),-w+(t)*1065,300)':y=300:enable='between(t,0,1):shortest=1'[merge1A]; [1:v]format=pix_fmts=yuva420p,scale=765:1083,fade=out:st=3:d=1:alpha=1 [overlay1B], [merge1A][overlay1B] overlay=300:300:enable='between(t,1,4)':shortest=1[merge1B]; [merge1B] drawtext=alpha=if(lt(t\,0.3)\,0\,if(lt(t\,1.3)\,(t-0.3)/1\,if(lt(t\,3)\,1\,if(lt(t\,4)\,(1-(t-3))/1\,0)))):fontcolor=ffffff:fontsize=64:text=test:x=200:y=200 [merge1C]; [2:v]format=pix_fmts=yuva420p,scale=765:1083,fade=in:st=4:d=1:alpha=1 [overlay2A], [merge1C:v][overlay2A] overlay=x='if(lte(-w+(t)*1065,300),-w+(t)*1065,300)':y=300:enable='between(t,4,5):shortest=1'[merge2A]; [2:v]format=pix_fmts=yuva420p,scale=765:1083,fade=out:st=7:d=1:alpha=1 [overlay2B], [merge2A][overlay2B] overlay=300:300:enable='between(t,5,8)':shortest=1[merge2B]; [merge2B] drawtext=alpha=if(lt(t\,4.3)\,0\,if(lt(t\,5.3)\,(t-4.3)/1\,if(lt(t\,7)\,1\,if(lt(t\,8)\,(1-(t-7))/1\,0)))):fontcolor=ffffff:fontsize=64:text=test:x=200:y=200 [merge2C]; matches no streams.
Error initializing complex filters: Invalid argument

我的 ffmpeg 命令如下所示:

ffmpeg -i concat-video.mp4  -loop 1 -i card1.jpg -loop 1 -i card2.jpg -filter_complex "[1:v]format=pix_fmts=yuva420p,scale=765:1083,fade=in:st=0:d=1:alpha=1 [overlay1A], [0:v][overlay1A] overlay=x='if(lte(-w+(t)*1065,300),-w+(t)*1065,300)':y=300:enable='between(t,0,1):shortest=1'[merge1A]; [1:v]format=pix_fmts=yuva420p,scale=765:1083,fade=out:st=3:d=1:alpha=1 [overlay1B], [merge1A][overlay1B] overlay=300:300:enable='between(t,1,4)':shortest=1[merge1B]; [merge1B] drawtext=alpha=if(lt(t\,0.3)\,0\,if(lt(t\,1.3)\,(t-0.3)/1\,if(lt(t\,3)\,1\,if(lt(t\,4)\,(1-(t-3))/1\,0)))):fontcolor=ffffff:fontsize=64:text=test:x=200:y=200 [merge1C]; [2:v]format=pix_fmts=yuva420p,scale=765:1083,fade=in:st=4:d=1:alpha=1 [overlay2A], [merge1C:v][overlay2A] overlay=x='if(lte(-w+(t)*1065,300),-w+(t)*1065,300)':y=300:enable='between(t,4,5):shortest=1'[merge2A]; [2:v]format=pix_fmts=yuva420p,scale=765:1083,fade=out:st=7:d=1:alpha=1 [overlay2B], [merge2A][overlay2B] overlay=300:300:enable='between(t,5,8)':shortest=1[merge2B]; [merge2B] drawtext=alpha=if(lt(t\,4.3)\,0\,if(lt(t\,5.3)\,(t-4.3)/1\,if(lt(t\,7)\,1\,if(lt(t\,8)\,(1-(t-7))/1\,0)))):fontcolor=ffffff:fontsize=64:text=test:x=200:y=200 [merge2C];" -pix_fmt yuva420p -map "[merge2C]" output.mp4

或者这里稍微格式化一下以提高可读性:

ffmpeg -i concat-video.mp4  -loop 1 -i card1.jpg -loop 1 -i card2.jpg -filter_complex "

# start of block for first input jpg
[1:v]format=pix_fmts=yuva420p,scale=765:1083,fade=in:st=0:d=1:alpha=1 [overlay1A],
[0:v][overlay1A] overlay=x='if(lte(-w+(t)*1065,300),-w+(t)*1065,300)':y=300:enable='between(t,0,1):shortest=1'[merge1A];
[1:v]format=pix_fmts=yuva420p,scale=765:1083,fade=out:st=3:d=1:alpha=1 [overlay1B],
[merge1A][overlay1B] overlay=300:300:enable='between(t,1,4)':shortest=1[merge1B];
[merge1B] drawtext=alpha=if(lt(t\,0.3)\,0\,if(lt(t\,1.3)\,(t-0.3)/1\,if(lt(t\,3)\,1\,if(lt(t\,4)\,(1-(t-3))/1\,0)))):fontcolor=ffffff:fontsize=64:text=test:x=200:y=200 [merge1C];

# start of block for second input jpg
[2:v]format=pix_fmts=yuva420p,scale=765:1083,fade=in:st=4:d=1:alpha=1 [overlay2A],
[merge1C:v][overlay2A] overlay=x='if(lte(-w+(t)*1065,300),-w+(t)*1065,300)':y=300:enable='between(t,4,5):shortest=1'[merge2A];
[2:v]format=pix_fmts=yuva420p,scale=765:1083,fade=out:st=7:d=1:alpha=1 [overlay2B],
[merge2A][overlay2B] overlay=300:300:enable='between(t,5,8)':shortest=1[merge2B];
[merge2B] drawtext=alpha=if(lt(t\,4.3)\,0\,if(lt(t\,5.3)\,(t-4.3)/1\,if(lt(t\,7)\,1\,if(lt(t\,8)\,(1-(t-7))/1\,0)))):fontcolor=ffffff:fontsize=64:text=test:x=200:y=200 [merge2C];

" 
-pix_fmt yuva420p -map "[merge2C]" output.mp4

希望有人能给我提示,这让我发疯:D

我尝试了几次语法更改,但总是出错。

问题似乎是输出“merge1C”(包括第一个 jpg 叠加层的淡入淡出、幻灯片、文本和淡出)与另一个 jpg 的第二个块之间的链。

ffmpeg video-processing
1个回答
0
投票

@Gyan 的评论解决了这个问题

© www.soinside.com 2019 - 2024. All rights reserved.