# webcamd unable to view video



## sham1810 (Sep 7, 2018)

Hi,

I'm trying to test if my camera Logictech C922 works with FreeBSD 11.2 installed on my system.
I want to view the video output and the following is webcamd output:


```
root@amd-sham:~ # webcamd
Available device(s):
webcamd [-d ugen0.1] -N 0x1022-XHCI-root-HUB -S unknown -M 0
webcamd [-d ugen0.3] -N CHICONY-HP-Basic-USB-Keyboard -S unknown -M 0
webcamd [-d ugen0.4] -N Logitech-USB-Optical-Mouse -S unknown -M 0
webcamd [-d ugen0.5] -N ASIX-Elec--Corp--AX88179 -S 0000249B168241 -M 0
webcamd [-d ugen0.2] -N vendor-0x046d-C922-Pro-Stream-Webcam -S F626FA7F -M 0
Show webcamd usage:
webcamd -h
```


```
root@amd-sham:~ # webcamd -d ugen0.2 -N vendor-0x046d-C922-Pro-Stream-Webcam -S F626FA7F -M 0
Attached to ugen0.2[0]
Creating /dev/video0
```

After which I run:

```
root@amd-sham:~ # pwcview
Webcam set to: 320x240 (sif) at 5 fps
```

There's no output in the launched window, it's just green background.
Any idea what could be the problem here?
I'm new to FreeBSD.


Update:


```
root@amd-sham:~ # pwcview -s svga -f 30
Webcam set to: 800x600 (svga) at 30 fps
libv4l2: error got 4 consecutive frame decode errors, last error: v4l-convert: libjpeg error: Start Of Scan: 70 components
Error reading from webcam: Input/output error
root@amd-sham:~ # pwcview -s svga -f 30
Webcam set to: 800x600 (svga) at 30 fps
^Croot@amd-sham:~ # pwcview -s xga -f 30
Webcam set to: 960x720 (xga) at 30 fps
libv4l2: error got 4 consecutive frame decode errors, last error: v4l-convert: libjpeg error: End Of Image
Error reading from webcam: Input/output error
root@amd-sham:~ #
```

I can see a scattered video feed at svga(800X600) resolution, higher resolution gets the above mentioned error, lower resolution is the same (green background).
I tried using cheese, but I get the same problem as above.


----------



## fernandel (Sep 16, 2018)

And you load a module "cuse"?
I built webcamd without hal and in /boot/loader.conf I have

```
cuse_load="YES"
```
And if I am using it I use it as user which is member of webcamd and videogroup. And works.


----------



## sham1810 (Sep 17, 2018)

fernandel said:


> And you load a module "cuse"?
> I built webcamd without hal and in /boot/loader.conf I have
> 
> ```
> ...



I created a user and added it to wheel, operator, webcamd, video groups (by editing /etc/group), in this scenario, webcamd was not able to find any devices. I think its due to lack of permissions but I'm not sure what other groups the user needs to be a part of. (usbconfig threw a lack of permission error).

Update:
I have added vfs.usermount=1 in /etc/sysctl.conf

What would the content of /etc/devfs.conf look like?
usb devices appear as /dev/ugen0.1/2/3/4/5


----------



## fernandel (Sep 18, 2018)

I have for usb devices:


```
perm    /dev/da0        0666
perm    /dev/da1        0666
perm    /dev/da2        0666
perm    /dev/da3        0666
perm    /dev/video0     0666
```


----------



## sham1810 (Sep 18, 2018)

fernandel said:


> I have for usb devices:
> 
> 
> ```
> ...



I'm able to use usbconfig if I chown /dev/usb/* to my user. Else, i get this error:

`amd@amd-sham:~ % usbconfig
No device match or lack of permissions.
amd@amd-sham:~ % webcamd
Available device(s):
Show webcamd usage:
webcamd -h
webcamd: No USB device match found`

And I also have to chown /dev/cuse in order to start webcamd.
After I chown everything, I'm still unable to start webcamd. It gives this message that it's already running but when I check "ls /dev/', there is no /dev/video0

`amd@amd-sham:~ % webcamd -d ugen0.3
Cannot set realtime priority
Linux video capture interface: v2.00
IR NEC protocol handler initialized
IR RC5(x/sz) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
IR SANYO protocol handler initialized
IR LIRC bridge handler initialized
IR XMP protocol handler initialized
b2c2-flexcop: B2C2 FlexcopII/II(b)/III digital TV receiver chip loaded successfully
USB Video Class driver (1.1.1)
cpia2: V4L-Driver for Vision CPiA2 based cameras v3.0.1
pvrusb2: V4L in-tree version:Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner
pvrusb2: Debug mask is 31 (0x1f)
USBVision USB Video Device Driver for Linux : 0.9.11
Webcamd is already running for ugen0.3.0
amd@amd-sham:~ %`

I have added user(amd) to group "operator". What seems to be missing here? I feel I should not have to chown everything to my user in order to make this work.

I have set perm /dev/video0 0666, but I suppose that would only make sense once webcamd is able to create /dev/video0


----------



## sham1810 (Sep 25, 2018)

fernandel said:


> I have for usb devices:
> 
> 
> ```
> ...



Can you provide the libjpeg version you are using along with webcamd?


----------



## BSDUser (Feb 20, 2019)

news? i have same problem


----------



## olli@ (Feb 20, 2019)

I once had a Logitech C210 (don't have it anymore, so I don't know if this still applies).
To get it working correctly, it required the following command *after* a webcam application (skype, pwcview) was started:
`usbconfig -d 1.2 do_request 0x22 0x01 0x100 0x86 0x03 0x80 0xBB 0x00`
Alternatively, use that command _twice_, with one device reset in between (`usbconfig -d 1.2 reset`).
Here, 1.2 is the USB address of the camera (in the OP's case it would be 0.2).

*Caution:* I don't know how similar the C210 and C922 are. Maybe they're completely different, and the above command causes it to catch fire and burn down. Or to start running in circles and chasing your cat.


----------



## BSDUser (Feb 21, 2019)

nothing......i tried but i see only grren window! I have a dell xps 13 9333. In linux work all devices also touchscreen. I'm trying to configure one device at a time. At the moment I was able to configure only the graphics driver. It is a difficult mission


----------



## Abhid (Sep 1, 2019)

Hi. My Dell Inspiron laptop has an integrated webcam. 
I too installed webcamd without HAL. I also installed v4l_compat, libv4l and pwcview. I manually added the entry `perm /dev/video0` into the file `/etc/devfs.conf` (it was not there earlier, and neither did /dev/video0 exist).
Like user Sham1810, I too added the line `vfs.usermount=1` in `/etc/sysctl.conf`.

But running the command `webcamd` just results in `illegal user name`. Running `pwcview` also outputs the same error.

What step did I miss ?


----------



## fernandel (Sep 1, 2019)

Abhid said:


> Hi. My Dell Inspiron laptop has an integrated webcam.
> I too installed webcamd without HAL. I also installed v4l_compat, libv4l and pwcview. I manually added the entry `perm /dev/video0` into the file `/etc/devfs.conf` (it was not there earlier, and neither did /dev/video0 exist).
> Like user Sham1810, I too added the line `vfs.usermount=1` in `/etc/sysctl.conf`.
> 
> ...


Did you put in /boot/loader.conf

```
cuse_load="YES"
```
or use kldload?


----------



## Abhid (Sep 1, 2019)

fernandel said:


> Did you put in /boot/loader.conf
> 
> ```
> cuse_load="YES"
> ...



fernandel, I've put `cuse_load="YES"` in my /boot/loader.conf.

Regarding kldload, I ran the command `sysrc "kldload_enable=YES"` which output `kldload_enable: YES -> YES`. However, when I run the command `service "kldload" start` it outputs `kldload does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable`


----------



## sidetone (Sep 1, 2019)

Abhid said:


> service "kldload" start


Service is not supposed to be with "kldload". It's supposed to be the file in /usr/local/etc/rc.d/ that relates to cuse.
`service cuse onestart`, `service cused onestart` or the right file name. You may need to use onestart, instead of start.


----------



## Abhid (Sep 2, 2019)

sidetone said:


> It's not supposed to be kldload. It's supposed to be the file in /usr/local/etc/rc.d/ that relates to cuse.
> `service cuse onestart`, `service cused onestart` or the right file name. You may need to use onestart, instead of start.


sidetone, the commands `service cuse onestart` and `service cused onestart` resulted in `cuse does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable`

Which is the file in `/usr/local/etc/rc.d` that should be used to start it ?

Edit: I also ran `/etc/rc.d/devd restart` and that worked fine.

`dmesg` tells that the Integrated WebCam is on ugen1.3. But then going ahead, *webcamd* is not recognized as a command, and I can't proceed.


----------



## sidetone (Sep 2, 2019)

`kldload cuse`, it doesn't look like a service. Then `kldstat` to see it. `kldunload`, unloads it.

cuse(3) says load it in /boot/loader.conf. I see people often suggest alternatively to use /etc/rc.conf for modules or daemons that don't need to be on at boot time. I'm not sure if this applies to cuse.


----------



## Abhid (Sep 2, 2019)

Well, I ran `kldload cuse` outputs `kldload: can't load cuse: module already loaded or in kernel`

Since its already loaded, running `kldstat` outputs `1 0xffffffff82681000     bf70 cuse.ko` amongst other entries.

With that done, I ran `dmesg` to get the entry of ugen 1.3, corresponding to the IntegratedWebcamHD at ubus1.

Then I ran `webcamd -d ugen1.3 -i 0 -v 0` but it outputs `webcamd: webcamd: illegal user name` This is where it's stuck.


----------



## fernandel (Sep 2, 2019)

Is your user member of  webcamd and video  group?


----------



## olli@ (Sep 2, 2019)

Abhid said:


> Then I ran `webcamd -d ugen1.3 -i 0 -v 0` but it outputs `webcamd: webcamd: illegal user name` This is where it's stuck.



Did you run that command as root user?
Does the “webcamd” user _and_ group exist? (Try `grep webcamd /etc/passwd /etc/group`)


----------



## Abhid (Sep 3, 2019)

olli@ said:


> Did you run that command as root user?
> Does the “webcamd” user _and_ group exist? (Try `grep webcamd /etc/passwd /etc/group`)


olli@, sorry for the delayed reply. I ran that as the root user itself. Upon executing `grep webcamd /etc/passwd /etc/group` this is the output:

`root@freebsd:~ # grep webcamd /etc/passwd /etc/group
/etc/passwd:webcamd:*:145:145:Webcamd user:/var/empty:/usr/sbin/nologin
/etc/group:webcamd:*:145:root`


----------



## olli@ (Sep 4, 2019)

Actually I can't image why it would print that error message when you execute that command as root, and the webcamd user and group exist. At least `/usr/local/sbin/webcamd -l` _should_ work and list one or more devices without error. If it doesn't, the problem must be somewhere else. Maybe try to reinstall the port / package.


----------



## Abhid (Sep 4, 2019)

That command outputs the same thing, `webcamd: webcamd: illegal user name`.

I've already de-installed and re-installed webcamd 3 times. Tried changing `cuse_load="YES"` to `cuse4bsd_load="YES"` _*even though I have a 12.0_RELEASE*_ because as mentioned in this thread, it somehow worked for another guy.

I think the main problem is that /dev/video0 itself doesn't exist fr some reason. Even though I put the entry `perm /dev/video0 0666` in the file `/etc/devfs.conf`......nothing happened.

The only saving grace is that the Integrated webcam is detected by `dmesg` as
`ugen1.3: <CN0F08KGLOG00774A7SVA02 IntegratedWebcamHD> at usbus1`

If it helps, my `/etc/rc.conf` has the following entries:

`webcamd_device_0_name="<CN0F08KGLOG00774A7SVA02 IntegratedWebcamHD> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)"
webcamd_enable="YES"
kldload_enable="YES"
devfs_system_ruleset="system"`


----------



## olli@ (Sep 4, 2019)

Abhid said:


> That command outputs the same thing, `webcamd: webcamd: illegal user name`.


That's really strange.



> I've already de-installed and re-installed webcamd 3 times. Tried changing `cuse_load="YES"` to `cuse4bsd_load="YES"` _*even though I have a 12.0_RELEASE*_ because as mentioned in this thread, it somehow worked for another guy.


No, `cuse_load` is correct for FreeBSD 12. I'm surprised that the cuse4bsd_kmod port doesn't refuse to build under FreeBSD 12 – I think this is a bug.

Type `kldstat`. If it lists cuse, then it's ok. If it doesn't list cuse, then you need to find out why the kernel module isn't loaded. In this case, try `kldload cuse` to load the module manually.



> I think the main problem is that /dev/video0 itself doesn't exist fr some reason. Even though I put the entry `perm /dev/video0 0666` in the file `/etc/devfs.conf`......nothing happened.


No, the main problem is that webcamd doesn't work (because something seems to be incorrectly configured on your machine). After all, the device /dev/video0 is created by webcamd (with the help of CUSE). If webcamd isn't running, you won't get the device.

Note: /etc/devfs.conf is only consulted during boot. But at that time, webcamd doesn't run yet, so /dev/video0 does not exist yet, so the entry in /etc/devfs.conf has no effect. You might want to make an entry in /etc/devfs.rules – these are rules for dynamic devices created after the system has booted. Such an entry would look like this:

```
add path 'video0' mode 0660 group webcamd
```
However, I think those settings are the defaults of webcamd anyway, so it's not necessary to make an entry at all.
*Important:* Note that it is a very bad idea to use permissions 0666, because then every unprivileged process can access your camera.



> If it helps, my `/etc/rc.conf` has the following entries:
> `webcamd_device_0_name="<CN0F08KGLOG00774A7SVA02 IntegratedWebcamHD> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)"
> webcamd_enable="YES"
> kldload_enable="YES"
> devfs_system_ruleset="system"`


Please remove *all* of those lines *except* for `webcamd_enable="YES"`, then reboot. Attach your camera. Check if webcamd has been started automatically. If it didn't, type `/usr/local/sbin/webcamd -l` as root.

If that still prints the same error message, I'm out of ideas.  Maybe I would try to truss(1) or ktrace(1) webcamd in order to find out what problem it has exactly with what username.


----------



## Abhid (Sep 4, 2019)

olli@ said:


> Type `kldstat`. If it lists cuse, then it's ok. If it doesn't list cuse, then you need to find out why the kernel module isn't loaded. In this case, try `kldload cuse` to load the module manually.


kldstat resulted in `2    1 0xffffffff8263e000     bf70 cuse.ko` as one of the entries.



> No, the main problem is that webcamd doesn't work (because something seems to be incorrectly configured on your machine). After all, the device /dev/video0 is created by webcamd (with the help of CUSE). If webcamd isn't running, you won't get the device.
> 
> Note: /etc/devfs.conf is only consulted during boot. But at that time, webcamd doesn't run yet, so /dev/video0 does not exist yet, so the entry in /etc/devfs.conf has no effect. You might want to make an entry in /etc/devfs.rules – these are rules for dynamic devices created after the system has booted. Such an entry would look like this:
> 
> ...


OK I just found that `/etc/devfs.rules` doesn't exist. Do I have to create it and add the entry `add path 'video0' mode 0660 group webcamd` over there ?

If it helps, webcamd is called during booting also. It prints the same error message `webcamd: Illegal user` 3 times.



> Please remove *all* of those lines *except* for `webcamd_enable="YES"`, then reboot. Attach your camera. Check if webcamd has been started automatically. If it didn't, type `/usr/local/sbin/webcamd -l` as root.
> 
> If that still prints the same error message, I'm out of ideas.  Maybe I would try to truss(1) or ktrace(1) webcamd in order to find out what problem it has exactly with what username.


OK. I'll try resolving the issue with the non-existent file, /etc/devfs.rules. If that also doesn't work, then I'll use truss and ktrace and probably a clean installation from scratch.

If it helps, `/usr/local/etc/devd/webcamd.conf` is created. Any entries to be added in that ? Also, mine is an *Integrated WebCam*, and not an externally attached one.


----------



## olli@ (Sep 5, 2019)

Abhid said:


> kldstat resulted in `2    1 0xffffffff8263e000     bf70 cuse.ko` as one of the entries.


Very good. So CUSE is _not_ the problem.


> OK I just found that `/etc/devfs.rules` doesn't exist. Do I have to create it and add the entry `add path 'video0' mode 0660 group webcamd` over there ?


No, let’s first try to get webcamd working, so you get /dev/video0 at all. You don't need any devfs configuration for that – That's only for setting ownership and permissions on an _existing_ entry in /dev, if necessary.


> If it helps, `/usr/local/etc/devd/webcamd.conf` is created. Any entries to be added in that ?


No, you don't have to touch it.


> Also, mine is an *Integrated WebCam*, and not an externally attached one.


That shouldn't matter, as long as it is attached to USB, externally or internally. I assume it is listed when you type `usbconfig` as root user, isn't it?


----------



## Abhid (Sep 7, 2019)

Finally it worked. Thanks a lot, Olli@and fernandel. Actually, earlier I should've heeded fernandel's query about webcamd not being in the user group. I didn't understand what that meant.

olli@, it was all about webcamd as you mentioned. I got that right, and everything worked.

I just de-installed and re-installed webcamd with the following commands below:
`cd /usr/ports/multimedia/webcamd

make deinstall

make "WITHOUT=HAL" "WITH=VT_CLIENT VT_SERVER" install clean`
The next command was the clincher. As mentioned by SirDice here, it somehow fixes the issue of user databases being out of sync.
`/usr/sbin/pwd_mkdb -p /etc/master.passwd`
That's it. v4l_compat, libv4l and pwcview were already installed earlier, and I didn't have to do anything else regarding them.

Then I rebooted my machine, and went to this site to check the webcam and it worked.

Hope it helps some other lost soul, who is diligently following all steps and yet is *stuck badly*. I hope the issue of user databases being out of sync is resolved by FreeBSD.


----------

