When you plug two image sequences of different lengths into ImageMagick it will produce an expected nice looking mosaic, but once the shorter sequence ends, it instantly stretches the remaining sequence to fill the screen.

My guess is that we probably need to somehow generate the missing frames for the shorter video (either by creating black images, or freezing the last frame).

But I'm clueless on how that could be done. I will appreciate any tips to solving this puzzle.

I extract image sequences from mp4 files.