Using a webcam on FreeBSD in web browsers
April 19, 2020
Guides to enable webcam support in FreeBSD seem to stop short of using the webcam in a browser (e.g. Chrome or Firefox). This article describes how I've been able to use the webcam on FreeBSD 12.1-RELEASE-p3 with Chromium 81.0.4044.113 and Firefox 75.0 (currently both from the 'latest' branch of packages).
webcamd, e.g. using
pkg install webcamd. Load it at boot by adding the following line to
webcamd_enable="YES". If you have multiple webcams on your system (e.g. visible light and IR), you'll have to add a line specifying the location of each camera on the USB bus, e.g.
webcamd_0_flags="-d ugen0.6" in my case (see
man 8 webcamd and
man 8 usbconfig). You'll also need to load the
cuse kernel module, which you can do at boot by adding
To get everything going without rebooting, load the kernel module with
kldload cuse and start
service webcamd start.
You can test the webcam with
pwcview -d /dev/video0. Be sure to read the
man page for all the options (resolution, framerate).
To actually use the webcam in browsers, you'll need to install a couple more packages:
pkg install v4l-utils v4l_compat. With these video4linux packages installed, the webcam should be available in Chrome and Firefox.