Reputation: 171
I've got two png image sequences with 30 frames each i'm trying to blend together. The problem is that some of the images are in the rgb24 color space while some are in rgba. Blending the two 30-frame animations together causes it to loose frames - the output is only 26 frames long and the two individual strips out-of-synch.
Command used:
ffmpeg -i a_%04d.png -i b_%04d.png -c:v libvpx -crf 4 -b:v 20M -filter_complex "blend=average" ab.webm
Result:
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%
Creating videos from the individual sequences does not create this problem, it only occurs when blending them together.
Any idea how i can solve this problem or convert both inputs to the rgb24 format first (if that would help)?
Upvotes: 0
Views: 507
Reputation: 93291
The issue is that the pixel format within each input changes mid-way. This causes the filtergraph to reinitialize and buffered frames get dropped.
Suppress reinitialization and convert to a command pixel format before blending.
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
Upvotes: 1