'Failed to open video device /dev/video0: Permission denied'

Forum for questions and support relating to the 1.28.x releases only.
Locked
swulf
Posts: 15
Joined: Tue Jun 30, 2015 4:07 am

'Failed to open video device /dev/video0: Permission denied'

Post by swulf »

Hello,

I have Zoneminder V1.28.1 installed under Ubuntu Server 14.04.3 LTS. I'm testing with a single Logitech USB camera. Zoneminder runs, I can access the web interface and I've set up a monitor with the camera, but I get no video from it. The Zoneminder console displays (under the Source column) '/dev/video0 (0)' in orange.

1) lsusb shows the camera:

Bus 001 Device 004: ID 046d:08dd Logitech, Inc. QuickCam for Notebooks

2) zmu -d /dev/video0 -q -v returns something odd:

Error, failed to enumerate standard 0: Success

3) Permissions on /dev/video0:

ls -al /dev/video0
crwxrwxrwx 1 root video 81, 0 Aug 14 07:02 /dev/video0

4) cat /etc/group contains this (amongst others):

video:x:44:www-data

5) v4l-info returns info about the camera:

### v4l2 device info [/dev/video0] ###
general info
VIDIOC_QUERYCAP
driver : "gspca_zc3xx"
card : "USB Camera (046d:08dd)"
bus_info : "usb-0000:00:14.0-3"
version : 3.19.8
capabilities : 0x85200001 [VIDEO_CAPTURE,?,READWRITE,STREAMING,(null)]

standards

inputs
VIDIOC_ENUMINPUT(0)
index : 0
name : "gspca_zc3xx"
type : CAMERA
audioset : 0
tuner : 0
std : 0x0 []
status : 0x0 []

video capture
VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE)
index : 0
type : VIDEO_CAPTURE
flags : 1
description : "JPEG"
pixelformat : 0x4745504a [JPEG]
VIDIOC_G_FMT(VIDEO_CAPTURE)
type : VIDEO_CAPTURE
fmt.pix.width : 640
fmt.pix.height : 472
fmt.pix.pixelformat : 0x4745504a [JPEG]
fmt.pix.field : NONE
fmt.pix.bytesperline : 640
fmt.pix.sizeimage : 113870
fmt.pix.colorspace : JPEG
fmt.pix.priv : 4276996862

6) I turned on debugging and looked at the log files. One zm_debug log shows:

08/14/15 06:00:03.429537 zmc_dvideo0[15892].FAT-zm_local_camera.cpp/673 [Failed to open video device /dev/video0: Permission denied]

I'm at a loss. =( Could anyone offer some advice on how to proceed from here?

Thanks.
PacoLM
Posts: 971
Joined: Wed Dec 02, 2009 9:55 pm
Location: Spain

Re: 'Failed to open video device /dev/video0: Permission den

Post by PacoLM »

Try to run this commands as root:

adduser www-data video
usermod -a -G video www-data

Post results

Hope it helps,

PacoLM

After more than 15 years, no longer using ZM as surveillance system.
Now in the dark side, using a commercial system...
swulf
Posts: 15
Joined: Tue Jun 30, 2015 4:07 am

Re: 'Failed to open video device /dev/video0: Permission den

Post by swulf »

Here is what I did.

x@y:~$ adduser www-data video
adduser: Only root may add a user or group to the system.
x@y:~$ sudo adduser www-data video
[sudo] password for x:
The user `www-data' is already a member of `video'.
x@y:~$ usermod -a -G video www-data
usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.
x@y:~$ sudo usermod -a -G video www-data
x@y:~$

Did not make any difference, even after restarting the Zoneminder service.
PacoLM
Posts: 971
Joined: Wed Dec 02, 2009 9:55 pm
Location: Spain

Re: 'Failed to open video device /dev/video0: Permission den

Post by PacoLM »

Try to run also this other command:
sudo chmod 777 /dev/video0
and
sudo a2enmod cgi
Restart Zoneminder, good luck

PacoLM

After more than 15 years, no longer using ZM as surveillance system.
Now in the dark side, using a commercial system...
swulf
Posts: 15
Joined: Tue Jun 30, 2015 4:07 am

Re: 'Failed to open video device /dev/video0: Permission den

Post by swulf »

x@y:~$ sudo chmod 777 /dev/video0
[sudo] password for x:
x@y:~$ sudo a2enmod cgi
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Enabling module cgi.
To activate the new configuration, you need to run:
service apache2 restart
x@y:~$ service apache2 restart
* Restarting web server apache2 [fail]

Not sure why this failed.

Followed this restarting Zoneminder from the Zoneminder console page. No change.

Next, I rebooted the PC on which Zoneminder runs. When it came back, I restarted Zoneminder from the console (it didn't start automatically) and this time opening the Monitor-1 link on the console page shows me a video feed!

It looks like the missing link was enabling the Apache cgi module.

Fantastic, thanks very much for your help PacoLM!
PacoLM
Posts: 971
Joined: Wed Dec 02, 2009 9:55 pm
Location: Spain

Re: 'Failed to open video device /dev/video0: Permission den

Post by PacoLM »

Congratulations!

After more than 15 years, no longer using ZM as surveillance system.
Now in the dark side, using a commercial system...
bminty
Posts: 1
Joined: Sat Sep 30, 2017 12:40 pm

Re: 'Failed to open video device /dev/video0: Permission denied'

Post by bminty »

Had the same problem I just ran sudo chmod 777 /dev/video0 and restarted the camera and it worked.
mikb
Posts: 585
Joined: Mon Mar 25, 2013 12:34 pm

Re: 'Failed to open video device /dev/video0: Permission denied'

Post by mikb »

Directly setting permissions on /dev/anything can work short term, and fail as soon as you replug (for a USB device) or reboot (for PCI cards etc.)

If you find this fix is only temporary, then you may need to look at udev rules, or whatever your system uses, to enforce the correct permissions.
DennisFaucher
Posts: 3
Joined: Fri Sep 11, 2020 1:48 pm

Re: 'Failed to open video device /dev/video0: Permission den

Post by DennisFaucher »

PacoLM wrote: Fri Aug 14, 2015 10:34 pm Try to run this commands as root:

adduser www-data video
usermod -a -G video www-data

Post results

Hope it helps,

PacoLM
Thank you so much. Perfect.
Benjamin7845
Posts: 1
Joined: Fri Jul 01, 2022 10:12 pm

Re: 'Failed to open video device /dev/video0: Permission denied'

Post by Benjamin7845 »

I disabled SELinux solving this issue for me. I then ran the sealert command on the SELinux log file. Implemented the changes generated by the report. Next I enable SELinux with the new rules and modules configured. Everything works great. RHEL 8.6
Locked