--- myst: html_meta: "description lang=en": "Kasm Workspaces Webcam pass-through setup and usage. Use a real webcam from any Web Browser on a Kasm Workspace." "keywords": "Kasm, Webcam, Setup" "property=og:locale": "en_US" --- ```{title} Webcam Pass-through ``` # Webcam Pass-through Workspaces supports passing a webcam feed directly into the Kasm sessions. ```{raw} html

``` ## Configuration To enable this feature: 1. Set the `allow_kasm_webcam` {doc}`Group Setting ` to `true` prior to launching the session. 2. Launch a Kasm session. 3. Open the control panel on the left side of the session, and select *Webcam*. Please note that you may be prompted to grant browser permissions to access the webcam. ```{tip} You can select the webcam device to be used and adjust its settings by navigating to Webcam Settings in the Control Panel ``` ## More Details This feature works by connecting to the local webcam via the browser's Media Capture and Streams API. This process intercepts the video feed and directs it into a virtual webcam device mapped within the container. All programs within the session container that use the `/dev/video0` interface should be able to access this virtual webcam. ### Host Level Requirements To enable the webcam feature in Kasm, it is necessary to meet a critical host level requirement: the v4l2loopback kernel module must be installed and running on the host system. This kernel module facilitates the streaming of video content by creating multiple V4L2 loopback devices, making it possible for the video feed to be intercepted and redirected into a virtual webcam device mapped within the container. As part of the installation process, Kasm installs this kernel module on the following distributions: - Ubuntu 20.04 - Ubuntu 22.04 - Debian 10 - Debian 11 - Debian 12 However, this feature is not limited to the aforementioned distributions; it's supported on any distribution, provided the v4l2loopback kernel module is installed and active. If the module is already installed, its installation can be skipped using the `--skip-v4l2loopback` parameter. For distributions where Kasm does not pre-install this module, users will need to refer to their specific distribution's documentation or community resources for detailed installation instructions for the v4l2loopback module. In such a scenario, the module needs to be installed before the Kasm installation. ### Troubleshooting To check the status of the virtual webcam devices created by Kasm, you can consult the agent logs. These logs should provide you with a comprehensive rundown of the virtual devices, their respective statuses, and any operational anomalies that might have occurred. It's important to note that if there were pre-existing webcam devices on the host system, the Kasm installation will not create new virtual devices. This is because the v4l2loopback kernel module recognizes the existing devices and opts not to duplicate these within the system. If you don't observe any new devices after the Kasm installation, it's likely due to the presence of these pre-existing devices. #### Known issues ##### Kernel lacks videodev Many cloud hosting providers provide custom Linux kernels for all flavors of Linux they provide. In most cases these Kernels will pull out modules that are deemed superfluous for a Linux server and conventionally only used on a Linux desktop. One of these modules is **videodev** which is critical for webcam pass-through to function. The error will resemble: ``` modprobe: FATAL: Module videodev not found in directory /lib/modules/Kernel-Version ``` This can be resolved by installing the extra modules package for your distribution: * **Debian/Ubuntu** - `sudo apt-get install -y linux-modules-extra-$(uname -r)` * **RHEL based** - `sudo dnf install -y kernel-modules-extra` After installation confirm functionality by running: ``` sudo modprobe videodev ``` The command will have no output that means it is working. ##### UEFI Secure Boot If using dedicated hardware or [Azure Linux Virtual Machines](https://azure.microsoft.com/en-us/products/virtual-machines/linux) Secure Boot will need to be disabled in order for webcam pass-through to function. The error to indicate this behavior is: ``` modprobe: ERROR: could not insert 'v4l2loopback': Key was rejected by service ``` On dedicated hardware Secure Boot will need to be disabled in the bios On Azure Linux Virtual Machines Secure Boot will be enabled by default and will need to be disabled at launch time or modified on a running Virtual Machine (This will reboot the Virtual Machine). Navigate to Services -> Virtual machines -> Add -> Virtual machine -> Instance details -> Security type -> Configure security features -> uncheck **Enable secure boot**. ```{figure} /images/user_guide/azure_secure_boot.webp :align: center **Disabling Secure Boot in Azure for Webcam-Passthrough** ``` ### Performance The overall system resource consumption in using Kasm, specifically in terms of CPU and memory usage, scales in relation to the number of sessions utilizing virtual webcam devices and the frame rate and quality settings chosen. As an example, a single session operating with default settings might utilize around 3% of the CPU's capacity. In contrast, if there are five concurrent sessions, this could potentially consume up to 20% of the CPU. However, bear in mind that these figures are estimations, and actual usage can vary based on numerous factors such as hardware specifications, other system loads, and specific application demands. Importantly, the frame rate selected by the user has a direct correlation with the utilization of internet bandwidth. Higher frame rates translate to a higher image transfer each second, which in turn demands more bandwidth.