由于颜色 space 不匹配,FFMPEG 丢帧

FFMPEG dropping frames due to color space mismatch

我有两个 png 图像序列,每个图像序列有 30 帧,我正在尝试将它们混合在一起。 问题是有些图像是 rgb24 颜色 space 而有些是 rgba。 将两个 30 帧动画混合在一起会导致帧丢失 - 输出只有 26 帧长并且两个单独的片段不同步。

使用的命令:

ffmpeg -i a_%04d.png -i b_%04d.png -c:v libvpx -crf 4 -b:v 20M -filter_complex "blend=average" ab.webm

结果:

Input #0, image2, from 'a_%04d.png':
Duration: 00:00:01.20, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgb24(pc), 1280x720 [SAR 2835:2835 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #1, image2, from 'b_%04d.png':
Duration: 00:00:01.20, start: 0.000000, bitrate: N/A
Stream #1:0: Video: png, rgb24(pc), 1280x720 [SAR 2835:2835 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[...]
Input stream #0:0 frame changed from size:1280x720 fmt:rgb24 to size:1280x720 fmt:rgba
Input stream #1:0 frame changed from size:1280x720 fmt:rgb24 to size:1280x720 fmt:rgba
Input stream #0:0 frame changed from size:1280x720 fmt:rgba to size:1280x720 fmt:rgb24
Input stream #1:0 frame changed from size:1280x720 fmt:rgba to size:1280x720 fmt:rgb24
Input stream #0:0 frame changed from size:1280x720 fmt:rgb24 to size:1280x720 fmt:rgba
Input stream #1:0 frame changed from size:1280x720 fmt:rgb24 to size:1280x720 fmt:rgba
Input stream #0:0 frame changed from size:1280x720 fmt:rgba to size:1280x720 fmt:rgb24
Input stream #1:0 frame changed from size:1280x720 fmt:rgba to size:1280x720 fmt:rgb24
frame=26 fps=13 q=0.0 Lsize=942kB time=00:00:01.12 bitrate=6886.5kbits/s
video:941kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.072036%

从各个序列创建视频不会产生此问题,只会在将它们混合在一起时出现。
知道我如何解决这个问题或首先将两个输入转换为 rgb24 格式(如果有帮助的话)吗?

问题是每个输入中的像素格式在中途发生变化。这会导致滤镜图重新初始化并丢弃缓冲帧。

禁止重新初始化并在混合前转换为命令像素格式。

ffmpeg -reinit_filter 0 -i a_%04d.png -reinit_filter 0 -i b_%04d.png -filter_complex "[0]format=rgb24[a];[1]format=rgb24[b];[a][b]blend=average" -c:v libvpx -crf 4 -b:v 20M ab.webm