How to use a camera as a webcam on linux

FIGURE 1 Sony a7R II

When working from home it’s important to have the best image quality when doing video chats.

It turns out you can use a high quality camera (DSLR, mirrorless camera, etc) as a webcam. The strategy is to use gphoto2 and v4l2loopback.

You can get v4l2loopback on github. It is also available as an AUR package on Arch Linux.

Meanwhile, gphoto2 should be packaged with most linux distributions.

Anyway, here are the commands I use:

sudo modprobe v4l2loopback devices=1 exclusive_caps=1 card_label="pupcam"
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video0