Reputation: 175
I'm trying to setup a Docker container for a streaming server, but I'm running into trouble when I try to access the host's webcam from within the container.
I am running the container with the following command: docker run -t -i --privileged --rm my/image /bin/bash
. VLC refuses to run as root, so I created a new user in the Dockerfile.
Here is the command I am using to test that the webcam is working:
cvlc v4l2:///dev/video2:chroma=h264 --sout '#std{access=file,mux=ps,dst=test.h264}'
. Everything works as expected on the host.
When I try to run the command in the container I see the following:
[0x7fc300003108] mux_ps mux: Open
[0x7fc300003108] main mux debug: using sout mux module "mux_ps"
[0x7fc300000b78] main stream output debug: muxer support adding stream at any time
[0x7fc300000b78] main stream output debug: muxer prefers to wait for all ES before starting to mux
[0x7fc300000f48] stream_out_standard stream out debug: using `file/ps://test.mp4'
[0x7fc300000f48] main stream out debug: using sout stream module "stream_out_standard"
[0x7fc308000ab8] main input debug: using timeshift granularity of 50 MiB, in path '/tmp'
[0x7fc308000ab8] main input debug: `v4l2:///dev/video2:chroma=h264' gives access `v4l2' demux `' path `/dev/video2:chroma=h264'
[0x7fc308000ab8] main input debug: creating demux: access='v4l2' demux='' location='/dev/video2:chroma=h264' file='/dev/video2:chroma=h264'
[0x7fc300004088] main demux debug: looking for access_demux module matching "v4l2": 20 candidates
[0x7fc300004088] v4l2 demux debug: opening device '/dev/video2'
[0x7fc300004088] v4l2 demux error: cannot open device '/dev/video2': Permission denied
[0x7fc300004088] v4l2 demux debug: opening device '/dev/video2'
[0x7fc300004088] v4l2 demux error: cannot open device '/dev/video2': Permission denied
[0x7fc300004088] main demux debug: no access_demux modules matched
[0x7fc308000ab8] main input debug: creating access 'v4l2' location='/dev/video2:chroma=h264', path='/dev/video2:chroma=h264'
[0x7fc300005988] main access debug: looking for access module matching "v4l2": 25 candidates
[0x7fc300005988] v4l2 access debug: opening device '/dev/video2'
[0x7fc300005988] v4l2 access error: cannot open device '/dev/video2': Permission denied
[0x7fc300005988] main access debug: no access modules matched
[0x7fc308000ab8] main input error: open of `v4l2:///dev/video2:chroma=h264' failed
[0x7fc308000ab8] main input error: Your input can't be opened
[0x7fc308000ab8] main input error: VLC is unable to open the MRL 'v4l2:///dev/video2:chroma=h264'. Check the log for details.
[0x927218] main playlist debug: dead input
I see the same permission denied message when I try to run similar tools like ffmpeg. Any hints as to where I might be going wrong?
Upvotes: 1
Views: 1790
Reputation: 175
The issue was that my user was not part of the video
group. Additionally, I had to change the permissions of the video devices to root.video
.
More information here: http://www.tldp.org/HOWTO/html_single/Webcam-HOWTO/#PERMISSIONS
Upvotes: 1