gpt4 book ai didi

animation - FFMPEG 由于色彩空间不匹配而丢帧

转载 作者:行者123 更新时间:2023-12-04 23:11:17 25 4
gpt4 key购买 nike

我有两个 png 图像序列,每个序列有 30 帧,我试图将它们混合在一起。
问题是有些图像在 rgb24 颜色空间中,而有些在 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 格式(如果有帮助的话)?

最佳答案

问题是每个输入中的像素格式在中途发生了变化。这会导致 filtergraph 重新初始化并且缓冲的帧被丢弃。
在混合之前抑制重新初始化并转换为命令像素格式。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

关于animation - FFMPEG 由于色彩空间不匹配而丢帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67524320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com