# Webcam does not work automatically



## martinrame (Feb 4, 2021)

Hi, I connected an USB cheap Web Cam to FreeBsd 12.2. It works without issues when I run `sudo webcamd -d ugen0.2`, now I would like it to start automatically without having to execute that command every time I need to use it.

Here's my /etc/rc.conf:


```
hostname="ws1.local.domain"
ifconfig_re0="inet 192.168.100.111 netmask 0xffffff00"
defaultrouter="192.168.100.1"
sshd_enable="YES"
kld_list="linux vmm nmdm nvidia nvidia-modeset fuse"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
dbus_enable="YES"
linux_load="YES"
vmm_load="YES"
nmdm_load="YES"
iohyve_enable="YES"
slim_enable="YES"
vboxnet_enable="YES"
vm_enable="YES"
vm_dir="zfs:datos/vms"
vm_list=""
vm_delay="5"
cloned_interfaces="bridge0 tap0 tap1 lo1"
ifconfig_bridge0="addm re0 addm tap0 addm tap1 addm lo1"
gateway_enable="YES"
pf_enable="yes"
pf_rules="/etc/pf.conf"
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
jupyter_enable="YES"
iocage_enable="YES"
jail_enable="YES"
jail_list="jupyterlab honeypot"
pflog0_enable="YES"
webcamd_enable="YES"
webcamd_device_0_name="GENERAL GENERAL WEBCAM"
webcamd_flags="-H"
```

in /boot/loader.conf I have:


```
...
cuse_load="YES"
```

When I run `webcamd` without parameters I get:


```
Available device(s):
Show webcamd usage:
webcamd -h
webcamd 19617 - - webcamd: No USB device match found
```

If I call it with `sudo webcamd`:


```
Available device(s):
Available device(s):
webcamd [-d ugen0.1] -N 0x1022-XHCI-root-HUB -S unknown -M 0
webcamd [-d ugen1.1] -N 0x1022-XHCI-root-HUB -S unknown -M 1
webcamd [-d ugen0.2] -N GENERAL-GENERAL-WEBCAM -S JH0319-20200710-v012 -M 0
webcamd [-d ugen0.3] -N ITE-Tech--Inc--ITE-Device-8595 -S unknown -M 0
webcamd [-d ugen0.4] -N Genius-Wireless-Device -S unknown -M 0
webcamd [-d ugen0.5] -N 2-4G-wireless-USB-Device-2-4G-wireless-USB-Device -S unknown -M 0
Show webcamd usage:
webcamd -h
```

My user leonardo is part of the `webcamd` group:


```
[leonardo@ws1 ~] $ groups
leonardo video webcamd vboxusers sudo
```

So, the webcam works without issues when I start `webcamd` with `sudo webcamd -d ugen0.2`, even I can use Zoom or Google Meet from my Firefox, but as I mentioned at the beginning of this post, I would like to avoid that command every time I need to use it.


----------



## SirDice (Feb 4, 2021)

Ownership off the /dev/usb/0.2.0 (where /dev/ugen0.2 points to) device are typically `root:operator` and the permissions are set so only root can read/write to it. You'll need to change those permissions and add yourself to the `operator` group. But as this is a dynamic device you will have to set those permissions each time you plug in the device. You can set those permissions automatically with devfs.conf(5) but if you have some other device plugged in as well the device number might change to /dev/ugen0.3 or /dev/ugen0.4, etc.


----------



## martinrame (Feb 4, 2021)

Uhmm, in my case the owner is `root:wheel`, see:


```
[leonardo@ws1 ~] $ sudo ls -lah /dev/ugen*
lrwxr-xr-x  1 root  wheel     9B  3 feb.  20:48 /dev/ugen0.1 -> usb/0.1.0
lrwxr-xr-x  1 root  wheel     9B  3 feb.  20:48 /dev/ugen0.2 -> usb/0.2.0
lrwxr-xr-x  1 root  wheel     9B  3 feb.  20:48 /dev/ugen0.3 -> usb/0.3.0
lrwxr-xr-x  1 root  wheel     9B  3 feb.  20:48 /dev/ugen0.4 -> usb/0.4.0
lrwxr-xr-x  1 root  wheel     9B  3 feb.  20:48 /dev/ugen0.5 -> usb/0.5.0
lrwxr-xr-x  1 root  wheel     9B  3 feb.  20:48 /dev/ugen1.1 -> usb/1.1.0
```

But I found the /dev/cuse device is owned by `root:operator`. 

If I run `sudo pw groupmod operator -m leonardo` my user is not added to the `operator` group, as you can see:


```
leonardo video webcamd vboxusers sudo
```


----------



## SirDice (Feb 4, 2021)

martinrame said:


> Uhmm, in my case the owner is `root:wheel`, see:


Look at the actual /dev/usb/* devices, not the /dev/ugen.* symlinks.



martinrame said:


> If I run `sudo pw groupmod operator -m leonardo` my user is not added to the `operator` group, as you can see:


Group membership is applied at login. It's not dynamic. So logoff and back in again.


----------



## chrbr (Feb 4, 2021)

martinrame said:


> webcamd -d ugen0.2


Would it be an option to add that command to the crontab(1) of root with the execution @reboot?
It is just an idea...


----------



## Martin Paredes (Feb 6, 2021)

martinrame said:


> When I run `webcamd` without parameters I get:
> 
> Code:
> Available device(s):
> ...


You should run (as root) `service webcamd start` or reboot your PC

multimedia/webcamd  is a daemon, so you manipulate it with the `service` command


----------

