Skip to content

Instantly share code, notes, and snippets.

@dreamcat4
Last active July 15, 2023 13:34
Show Gist options
  • Save dreamcat4/32fac8eb6f5db515b68d to your computer and use it in GitHub Desktop.
Save dreamcat4/32fac8eb6f5db515b68d to your computer and use it in GitHub Desktop.
How to Install Webcamd on FreeBSD, FreeNAS / NAS4Free / pfSense, with Finch v1.27 - http://dreamcat4.github.io/finch/

Webcamd How-To

First of all, visit the FreeBSD WebcamCompat page to check that your TV Tuner device is supported. Most popular webcams are compatible. Then follow the instructions on this page to install the webcamd program.

In some fewer cases, you may own a compatible PCI card, which is recognised by the system as a native PCI device. Those devices need their own special kernel module, and do not use webcamd at all. For example the Hauppauge WinTV HVR-4000. Which require the cx88 kernel modules to be loaded. You will instead need to follow the steps here for installing the cx88 device driver.

Most of these commands can just be copy-pasted. The webcamd program must be installed directly in Finch's chroot. This is because webcamd needs to create new device nodes e.g. /dev/dvb, etc. in '/dev/'. Such special files require 'mknod' cmd. That can't be created in a jail.

Update Finch

Update finch to version 1.27 or newer.

# Finch users should first update to get the latest fixes
[ "$(echo "$(finch --shortver) >= 1.27" | bc)" = 1 ] || sudo finch update -y

# Enter the finch chroot environment, as root
sudo finch chroot

Install cuse4bsd-kmod

# Update local pkgng database, to avoid 'failed checksum' for 'pkg install'
pkg update -f

# Download the cuse4bsd kernel module from pkgng
ASSUME_ALWAYS_YES="yes" pkg install "cuse4bsd-kmod"

# Finch users: Configure kldload to start cuse4bsd kernel module on boot up
# (other users should edit their loader.conf file instead).
sysrc "kldload_modules=$(sysrc -n kldload_modules 2&> /dev/null) cuse4bsd"

# Enable, start kldload system service
sysrc "kldload_enable=YES"
service "kldload" start

Install webcamd

# Build webcamd from ports (to avoid HAL dependancy)
cd /usr/ports/multimedia/webcamd && BATCH=YES make "WITHOUT=HAL" "WITH=VT_CLIENT VT_SERVER" install clean

# Replace the webcamd rc.d script with this improved version
fetch -q -o - "https://gist.githubusercontent.com/dreamcat4/3518679d6acf46d2ea41/raw/0f730e04363eac806af18adfa08bf34870f501d1/webcamd" > /usr/local/etc/rc.d/webcamd

# Make sure it is executable
chmod +x /usr/local/etc/rc.d/webcamd

Check webcamd works with your device

# Identify your TV Tuner device in the list of attached USB devices
usbconfig

# Check compatibility @ https://wiki.freebsd.org/WebcamCompat
# Look for it's firmware file @ http://linuxtv.org/downloads/firmware/

# If necessary, download your TV Tuner's firmware file from the web
# cd /boot/modules/ && fetch http://linuxtv.org/downloads/firmware/dvb-usb-dib0700-1.20.fw

# Find the USB device name. In this example, it is "SCEH-0036 SONY"
freenas // root^> usbconfig | grep -i sony
ugen7.3: <SCEH-0036 SONY> at usbus7, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)

# Test that webcamd recognizes your TV Tuner, and will create /dev/dvb/ device nodes
freenas webcamd/ root^> webcamd -d 7.3
Attached to ugen7.3[0]
Creating /dev/dvb/adapter0/demux0
Creating /dev/dvb/adapter1/demux0
Creating /dev/dvb/adapter0/dvr0
Creating /dev/dvb/adapter1/dvr0
Creating /dev/dvb/adapter0/frontend0
Creating /dev/dvb/adapter1/frontend0
Creating /dev/input/event0
^C

Configure webcamd

# Webcamd won't start unless you tell it which USB devices to connect to
sysrc "webcamd_device_0_name=SCEH-0036 SONY"

# For more ways to configure webcamd, please see the comments in the rc.d script
head -72 /usr/local/etc/rc.d/webcamd

# Enable the webcamd system service
sysrc "webcamd_enable=YES"
service "webcamd" start

# Check that webcamd comes up automatically during system startup
reboot
ls -lsa /dev/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment