I have 3 webcams which register in Ubuntu 18.04 as /dev/video0, /dev/video1 and /dev/video2. All three show up fine in Cheese and ffplay (but not vlc for some reason... not important for this question).
What I want is to open a viewing window and have the image shift automatically from device 0 to device 1 to device 2 and back to 0 every X seconds without the window closing or resizing.
I think the ultimate solution will come from creating a fake video device (let's say /dev/video3), watching it with a program and using ffmpeg or other command-line scripts to change the stream of /dev/video3. (v4l2loopback seemed promising)
Unfortunately, I have spent a few hours on this and gotten nowhere. Any help would be appreciated.
Assuming all 3 clips have the same properties, basic syntax is
This will show 5 seconds of video0 followed by 5s of video1 followed by 5s of video2.
Edit by OP: Using this suggestion, I was able to get this working for 4 cameras.
It defines 4 camera inputs, then does 3 video segments. The first video segment takes cams 0 and 1 and overlays 1 on top of 0 (but only for seconds 5-10). The second segment overlays cam 2 on the stream of cams 0+1 (but only for seconds 10-15). The third segment overlays cam 3 on the combined stream of cams 0+1+2 (but only for seconds 15-20). Each stream is only shown during its "turn" in the loop (again, multiples of 0-5, 5-10, 10-15, 15-20), governed by the overlay commands and the between+modulus magic suggested by Gyan.