8

I have different lxc containers running on my machine and a webcam is also attached. I want all of the lxc containers to access this camera. I came across 'v4l2-loopback' devices and found a way to add devices using;

modprobe v4l2loopback devices=3

And I directed the stream from /dev/video0 to the desired virtual video devices. My question is how to add and remove these v4l2loopback devices at runtime? I want to add/remove a device whenever any lxc container is launched/deleted. Any ideas?

Thanks!

umläute
  • 6,300
  • 1
  • 24
  • 48
beenum
  • 81
  • 1
  • 1
  • 2

2 Answers2

8

I don't have an elegant way to remove these devices other than force remove the v4l2loopback module:

sudo modprobe -r v4l2loopback
user278684
  • 81
  • 1
  • 2
0

If you are running the full up to date v4l2loopback driver from https://github.com/umlaeute/v4l2loopback, then you can use the v4l2loopback-ctl utility to add and remove devices while the module is installed using the command v4l2loopback-ctl add /dev/video2 and v4l2loopback-ctl delete /dev/video2.

Unfortunately, this is not the version that is currently in Debian, which is a mishmash of an old version and some code from the current version, and is still using the old (pre 2021) v4l2loopback-ctl and the driver with no dynamic device management.

Guss
  • 12,278
  • 2
  • 22
  • 39