You can use the powerful tool, FFMPEG, and a "fake" camera v4l2loopback.
Install ffmpeg
and v4l2loopback
first.
Then, check your existing video devices:
ls /dev/video*
Note the outputs. Now do:
sudo modprobe v4l2loopback devices=1 card_label="Very Real HD Webcam" exclusive_caps=1
This creates a video device.
Then use:
ffmpeg -i /dev/video0 -i /dev/video1 \
-filter_complex "[1:v]scale=500:-1[v2];[0:v][v2]overlay=main_w-overlay_w-5:5" \
-c:a copy -pix_fmt rgb24 -vsync 2 -f v4l2 /dev/video2
/dev/video0 and /dev/video1 are your real webcams. /dev/video2 is the device created by v4l2loopback. Change if necessary with outputs from the first ls
command.
You can test the video with
ffplay /dev/video2
There will still be some delays, but it should not be much of an issue. If there is a delay on only one of the cams (out of sync), there might be a framerate issue, which is what happened to me. Add -r
to specify input framerate (fps). You can find it out with ffprobe /dev/video0
for example.
ffmpeg -r 25 -i /dev/video0 -r 10 -i /dev/video1 \
-filter_complex "[1:v]scale=500:-1[v2];[0:v][v2]overlay=main_w-overlay_w-5:5" \
-c:a copy -pix_fmt rgb24 -vsync 2 -f v4l2 /dev/video2
Ffmpeg filter code taken from: https://superuser.com/a/1721227.
I'm not very good with ffmpeg filters, but you can do some googling to change it if you need. This one puts second cam to top right corner